#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
//#define int long long

const int mod = 998244353, N = 1e6 + 10;

int sum(int a, int b) {
    if (a + b >= mod) {
        return a + b - mod;
    }
    return a + b;
}

int raz(int a, int b) {
    if (a - b < 0) {
        return a - b + mod;
    }
    return a - b;
}

vector<int> g[N], dp[N];
int x[N], st[N], st2[N], pred[N];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    st2[0] = 1;
    for (int i = 1; i < N; ++i) {
        st2[i] = sum(st2[i - 1], st2[i - 1]);
    }
    for (int i = 1; i <= k; ++i) {
        int y;
        cin >> y;
        x[y] = 1;
    }
    for (int i = 2; i <= n; ++i) {
        int j;
        cin >> j;
        g[j].pb(i);
        pred[i] = j;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int kol = x[i] + (i == 1 ? 0 : sz(dp[pred[i]]) - 1);
        dp[i].resize(kol + 1);
        dp[i][0] = 1;
        for (int j = 0; j < sz(dp[i]); ++j) {
            if (i != 1 && j < sz(dp[pred[i]])) {
                dp[i][j] = (ll) dp[pred[i]][j] * (j + 1) % mod;
            }
            if (x[i] && j) {
                dp[i][j] = sum(dp[i][j], (i == 1 ? 1 :dp[pred[i]][j - 1]));
            }
            if (i == n && j == k) {
                ans = sum(ans, dp[i][j]);
            }
        }
    }
    cout << ans;
    return 0;
}