#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <experimental/random>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
using str = string;
using ld = long double;
const ll INF = 1e18, MOD = 998244353;
#define int long long
int binp(int v,int x) {
    if (x == 0) {
        return 1;
    }
    auto w = binp(v, x / 2);
    if (x % 2) {
        return w * w % MOD * v % MOD;
    }
    return w * w % MOD;
}

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
        //cout << "\n";
    }
}

vector<vector<int> > g;
vector<bool> us;

void solve() {
    int n, k;
    cin >> n >> k;
    us.resize(n);
    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        us[x - 1] = true;
    }
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
    }
    int ans = 1, cnt = 1;
    for (int i = 0; i < n; ++i) {
        if (us[i]) {
            cnt++;
        } else {
            ans *= (cnt);
            ans %= MOD;
        }
    }
    cout << ans;
}
