#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <map>
#include <random>
#include <ctime>
#include <algorithm>
#include <ctime>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <numeric>
#include <deque>

using namespace std;
using ll = long long;

ll mod = 998244353;

struct mll {
    ll val;
};

mll operator+ (mll a, mll b) {
    if (a.val+b.val > mod) return {a.val+b.val-mod};
    return {a.val+b.val};
}

mll operator- (mll a, mll b) {
    if (a.val-b.val < 0) return {a.val-b.val+mod};
    return {a.val-b.val};
}

mll operator* (mll a, mll b) {
    return {a.val*b.val%mod};
}

mll bin_st(mll a, ll b) {
    if (b == 1) {
        return a;
    }
    if (b == 0) {
        return {1};
    }
    if (b%2 == 1) {
        mll x = bin_st(a, b/2);
        return x*x*a;
    } else {
        mll x = bin_st(a, b/2);
        return x*x;
    }
}

vector <ll> p;
vector <vector <ll>> sn;
vector <ll> sz;

void dfs(int a) {
    for (auto b : sn[a]) {
        dfs(b);
        sz[a] += sz[b];
    }
    return;
}

int main() {
    ll n, k;
    cin >> n >> k;
    p.resize(n);
    sn.resize(n);
    sz.resize(n, 1);
    vector <ll> mas(k);
    for (int i = 0; i < k; ++i) cin >> mas[i];
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        sn[p[i]].push_back(i);
    }
    dfs(0);
    sort(mas.begin(), mas.end());
    mll ans = {1};
    ll l = 0;
    for (int i = 0; i < n; ++i) {
        if (l < k && mas[l] == i+1) {
            l++;
            continue;
        }
        ans = ans*((mll) {l+1});
    }
    cout << ans.val << '\n';
}