//#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

#define int long long

using namespace std;
using ll = long long;
using ld = long double;

const int INTI = 2e9 + 5, MAXN = 1e5 + 1, MOD = 998244353;
const ll INF = 4e18 + 5;

int binpow(int a, int b) {
    int pr = 1;
    while (b) {
        if (b & 1)
            pr = (pr * a) % MOD;
        b >>= 1;
        a = (a * a) % MOD;
    }
    return pr;
}

vector<vector<int> > g;
vector<int> problem;

int dfs(int v) {
    int cnt = 0;
    for (auto& to : g[v]) {
        cnt += dfs(to);
    }
    if (v == problem[0]) {
        int f = 1, ans = 0;
        vector<int> fact(cnt + 1, 1);
        for (int i = 2; i <= cnt; ++i)
            fact[i] = (fact[i - 1] * i) % MOD;
        vector<int> obrf(cnt + 1, 1);
        for (int i = 2; i <= cnt; ++i)
            obrf[i] = binpow(fact[i], MOD - 2);
        for (int i = 0; i <= cnt; ++i) {
            ans += (((fact[cnt] * obrf[i]) % MOD) * obrf[cnt - i]) % MOD;
            ans %= MOD;
        }
        cout << ans;
        exit(0);
    }
    return cnt + 1;
}

void solve() {
    int n, k;
    cin >> n >> k;
    problem.resize(k);
    g.resize(n + 1);
    for (auto& i : problem)
        cin >> i;
    for (int i = 2; i <= n; ++i) {
        int pr;
        cin >> pr;
        g[pr].push_back(i);
    }
    dfs(1);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}
