#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define asc(x) x.begin(), x.end()
#define des(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back
#define ll long long
#define db long double
#define fori(a, b) for (int i = (a); i < (b); ++i)
#define forj(a, b) for (int j = (a); j < (b); ++j)

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 gen(228);

const int N = 1e6 + 5, MOD = 998244353;

int f[N], frv[N], sz[N];
vector<int> g[N];

void dfs(int v) {
    sz[v] = 1;

    for (int u : g[v]) {
        dfs(u);

        sz[v] += sz[u];
    }
}

int pw(int x, int y) {
    if (x == 1) return 1;
    if (y == 1) return x;

    int _x = pw(x, y / 2);

    _x = (1ll * _x * _x) % MOD;
    if (y % 2) {
        _x = (1ll * _x * x) % MOD;
    }

    return _x;
}

int c(int n, int k) {
    return 1ll * f[n] * frv[k] % MOD * frv[n - k] % MOD;
}

void solve() {
    int n, k; cin >> n >> k;

    vector<int> pref(n, 0);
    fori(0, k) {
        int x; cin >> x;

        pref[x - 1]++;
    }

    fori(1, n) {
        int c; cin >> c;

        g[c - 1].pb(i);
    }

    int ans = 1, cnt = 1;
    fori(0, n) {
        if (pref[i]) {
            ++cnt;
            continue;
        }

        ans = (1ll * ans * cnt) % MOD;
    }

    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    f[0] = frv[0] = 1;
    fori(1, N) {
        f[i] = (1ll * f[i - 1] * i) % MOD;
        frv[i] = pw(f[i], MOD - 2);
    }

    int tt = 1;
    while (tt--) {
        solve();
        cout << "\n";
    }
}