#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

using namespace std;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ff first
#define ss second
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

constexpr int MOD = (int)998244353;

struct mint {
    int x;
    mint() : x(0) {}
    mint(int y) {
        if (y >= MOD) y -= MOD;
        if (y < 0) y += MOD;
        x = y;
    }
    mint(ll y) {
        if (y >= MOD) y %= MOD;
        if (y < 0) y += MOD;
        x = y;
    }
    mint operator+(const mint& b) const {
        return x + b.x;
    }
    mint operator-(const mint& b) const {
        return x - b.x;
    }
    mint operator*(const mint& b) const {
        return x * (ll) b.x;
    }
    mint& operator+=(const mint& b) {
        return *this = *this + b;
    }
    mint& operator-=(const mint& b) {
        return *this = *this - b;
    }
    mint& operator*=(const mint& b) {
        return *this = *this * b;
    }
};

struct point {
    ll x, y;

    point operator+(const point& b) const {
        return {x + b.x, y + b.y};
    }
    point operator-(const point& b) const {
        return {x - b.x, y - b.y};
    }
    ll operator*(const point& b) const {
        return x * b.x + y * b.y;
    }
    ll operator%(const point& b) const {
        return x * b.y - y * b.x;
    }
    ll len_sqr() const {
        return x * x + y * y;
    }
    ld len() const {
        return sqrtl(len_sqr());
    }
};

vector<vector<int>> g;
vector<bool> marked;
mint c[2001][2001];

mint binpow(mint x, int p) {
    mint res = 1;
    while (p) {
        if (p & 1) res *= x;
        x *= x;
        p >>= 1;
    }
    return res;
}

mint inv(mint x) {
    return binpow(x, MOD - 2);
}

void calc(int v, vector<mint>& amounts) {
    vector<vector<mint>> children; 
    for (int u : g[v]) {
        vector<mint> uamounts;
        calc(u, uamounts);
        children.push_back(uamounts);
    }
    sort(all(children), [](const vector<mint>& a, const vector<mint>& b) {
        return a.size() > b.size();
    });
    // int x = 1;
    // int prod = 1;
    int m = children.size();
    // for (int i = 0; i < m; i++) {
    //     x += children[i].size() - 1;
    //     prod *= children[i].size();
    // }
    vector<array<mint, 3>> ans;
    ans.push_back({0, 0, 1});
    ans.push_back({1, 0, 0});
    for (int i = 0; i < m; i++) {
        const vector<mint>& v = children[i];
        int k = v.size();
        vector<array<mint, 3>> new_ans(ans.size() + k - 1);
        for (int i = 0; i < ans.size(); i++) {
            for (int d = 0; d < 3; d++) {
                for (int j = 0; j < k; j++) {
                    new_ans[i + j][d] += ans[i][d] * v[j];
                }
            }
        }
        vector<mint> nv(k - 1);
        mint p = v[k - 1];
        for (int i = 1; i < k; i++) {
            for (int j = 0; j < i; j++) {
                nv[j] += v[i] * c[i][i - j];
            }
        }
        for (int i = 0; i < ans.size(); i++) {
            for (int d = 0; d < 3; d++) {
                int nd = min(2, d + 1);
                for (int j = 0; j < k - 1; j++) {
                    new_ans[i + j][nd] += ans[i][d] * nv[j];
                }
            }
        }
        swap(ans, new_ans);
    }
    for (int i = 0; i < ans.size(); i++) {
        if (marked[v]) {
            amounts.push_back(ans[i][2]);
        } else {
            amounts.push_back(ans[i][0]);
        }
    }
    while (amounts.size() && !amounts.back().x) amounts.pop_back();
    return;
}

signed main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 0; i <= 2000; i++) {
        c[i][i] = 1;
        c[i][0] = 1;
    }
    for (int i = 0; i <= 2000; i++) {
        for (int j = 1; j < i; j++) {
            c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
        }
    }
    int n, k;
    cin >> n >> k;
    g.resize(n);
    marked.resize(n);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        x--;
        marked[x] = true;
    }
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    vector<mint> amounts;
    calc(0, amounts);
    mint ans = 0;
    for (mint x : amounts) ans += x;
    cout << ans.x << '\n';
}