#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

long long sum(long long a, long long b) {
    if (a + b < MOD) {
        return a + b;
    }
    return a + b - MOD;
}

long long mul(long long a, long long b) {
    return (a * b) % MOD;
}

long long pow(long long a, int b) {
    if (b == 1) {
        return a;
    }
    if (b == 0) {
        return 1;
    }
    long long c = pow(a, b >> 1);
    if (b & 1) {
        return mul(a, mul(c, c));
    }
    return mul(c, c);
}

long long factor[(int)1e6 + 1];
long long rev_factor[(int)1e6 + 1];
vector<int> g[(int)1e6];
int red[(int)1e6];
vector<int> cnt(1e6, 1);
vector<set<int>> used(1e6);

void bfs(deque<pair<int, int>> &q) {
    while (!q.empty()) {
        int v = q.front().first, st = q.front().second;
        q.pop_front();
        for (auto to : g[v]) {
            if (used[to].find(st) == used[to].end()) {
                cnt[to]++;
                q.push_back({to, st});
                used[to].insert(st);
            }
        }
    }
}


void solve() {
    int n, k;
    cin >> n >> k;
    deque<pair<int, int>> q;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        red[x - 1] = 1;
        q.push_back({x - 1, x - 1});
        used[x - 1].insert(x - 1);
    }
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        g[x].push_back(i);
    }
    bfs(q);
    // for (int i = 0; i < n; i++) {
    //     cerr << cnt[i] << " ";
    // }
    // cerr << endl;
    long long ans = 1;
    for (int i = 0; i < 1e6; i++) {
        if (red[i] == 1) {
            cnt[i] = 1;
        }
        ans = mul(ans, cnt[i]);
    }
    cout << ans << endl;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    factor[0] = factor[1] = 1;
    for (int i = 2; i <= 1e6; i++) {
        factor[i] = factor[i - 1] * i;
    }
    for (int i = 0; i <= 1e6; i++) {
        rev_factor[i] = pow(factor[i], MOD - 2);
    }
    solve();
}