/*#include <bits/stdc++.h>

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

const ll mod = 998'244'353;

int add(int a, int b) {
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll mult(ll a, ll b) {
    return (a * b) % mod;
}

int binpow(int a, int p) {
    if (p == 0)
        return 1;
    if (p == 1)
        return a;
    int k = binpow(a, p / 2);
    if (p % 2 == 0)
        return mult(k, k);
    return mult(mult(k, k), a);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<int> v(k);
    for (int i = 0; i < k; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    int now = 0;
    ll am = 1;
    ll ans = 1;
    for (int i = 1; i <= n; ++i) {
        if (i == v[now]) {
            ++now;
            ++am;
        } else {
            ans = mult(ans, am);
        }
    }
    cout << ans;
}

#include <bits/stdc++.h>

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

const ll mod = 998'244'353;

ll add(ll a, ll b) {
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll diff(ll a, ll b) {
    if (a >= b)
        return a - b;
    return a - b + mod;
}

ll mult(ll a, ll b) {
    return (a * b) % mod;
}

int binpow(int a, int p) {
    if (p == 0)
        return 1;
    if (p == 1)
        return a;
    int k = binpow(a, p / 2);
    if (p % 2 == 0)
        return mult(k, k);
    return mult(mult(k, k), a);
}

vector<vector<int>> sons;
vector<int> sz;

void dfs(int v) {
    sz[v] = 1;
    for (auto u : sons[v]) {
        dfs(u);
        sz[v] += sz[u];
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, k;
    cin >> n >> k;
    int st;
    cin >> st;
    --st;

    sons.resize(n);
    sz.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        sons[p - 1].push_back(i);
    }

    dfs(0);

    ll ans = diff(binpow(2, sz[st]), 1);
    for (auto u : sons[st])
        ans = diff(ans, diff(binpow(2, sz[u]), 1));
    cout << ans << endl;
}*/

#include <bits/stdc++.h>
#define int long long

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

const ll mod = 998'244'353;

ll add(ll a, ll b) {
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll diff(ll a, ll b) {
    if (a >= b)
        return a - b;
    return a - b + mod;
}

ll mult(ll a, ll b) {
    return (a * b) % mod;
}

int binpow(int a, int p) {
    if (p == 0)
        return 1;
    if (p == 1)
        return a;
    int k = binpow(a, p / 2);
    if (p % 2 == 0)
        return mult(k, k);
    return mult(mult(k, k), a);
}

vector<vector<int> > sons;
set<int> ask;
vector<vector<ll> > amount;
int n;

void dfs(int v) {
    amount[v][0] = 1;
    amount[v][1] = 1;
    for (int j = 2; j < n; ++j)
        amount[v][j] = 0;

    for (auto u: sons[v]) {
        dfs(u);
        vector<int> sums(n);
        for (int i = 0; i < n; ++i) {
            ll sum = 0;
            for (int j = 0; j <= i; ++j)
                sum = add(sum, mult(amount[v][j], amount[u][i - j]));
            sums[i] = sum;
        }
        amount[v] = sums;
    }

    if (ask.count(v)) {
        vector<int> sums(n);
        sums[n - 1] = 0;
        for (int j = n - 2; j >= 0; --j) {
            sums[j] = sums[j + 1] + amount[v][j + 1];
        }
        amount[v] = sums;
    }
    
    for (int i = 1; i < n; ++i) {
        for (auto u : sons[v])
            amount[v][i] -= amount[u][i - 1];
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int k;
    cin >> n >> k;

    sons.resize(n);

    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        ask.insert(x - 1);
    }

    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        sons[p - 1].push_back(i);
    }

    amount.resize(n);
    for (int i = 0; i < n; ++i)
        amount[i].resize(n);

    dfs(0);
    for (auto &x : amount) {
        for (auto y : x) {
            cout << y << ' ';
        }
        cout << endl;
    }
    cout << amount[0][0];
}
