#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long

using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using ld = long double;

const int MOD = 998244353;

int sum(int x, int y) {
    if (x + y >= MOD) return x + y - MOD;
    return x + y;
} 

int mul(int x, int y) {
    return 1ll * x * y % MOD;
}

void summ(int &x, int y) {
    x = sum(x, y);
}

int timer = 0;

vector<vi> g;
vi par, x, good, sz, tin, tout, dep;
vector<vi> lca;

vector<vi> dp;

void dfsInit(int v, int p) {
    tin[v] = timer++;
    sz[v] = 1;
    dep[v] = dep[p] + 1;


    for (int u : g[v]) {
        if (u == p) continue;
        dfsInit(u, v);
        sz[v] += sz[u];
    }

    tout[v] = timer - 1;
}

int getLca(int u, int v) {
    if (dep[u] < dep[v]) swap(u, v);
    while (dep[u] > dep[v]) u = par[u];

    while (u != v) {
        u = par[u];
        v = par[v];
    }

    return v;
} 

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    g.resize(n);
    par.resize(n);
    x.resize(k);
    good.resize(n);
    tin.resize(n);
    tout.resize(n);
    sz.resize(n);
    lca.resize(n, vi(n + 1));
    dep.resize(n);
    // dp.assign(n, vi(n + 1));

    for (int i= 0; i < k; ++i) {
        cin >> x[i];
        --x[i];
        good[x[i]] = 1;
    }

    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;

        --p;
        g[p].pb(i);
        par[i] = p;
    }

    // cout << "e " << endl;
    dfsInit(0, 0);


    // cout << "e " << endl;


    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            lca[i][j] = getLca(i, j);
        }
    }

    vector<vi> dp(2, vi(1 << n));

    dp[0][0] = 1;

    // cout << "e " << endl;

    for (int i = 0; i < k; ++i) {
        dp[0].swap(dp[1]);
        dp[0].assign((1 << n), 0);
        
        for (int mask = 1; mask < (1 << n); ++mask) {
            for (int sub = mask; sub > 0; sub = (sub - 1) & mask)  {
                vi vs;
                for (int v = 0; v < n; ++v) {
                    if ((sub >> v) & 1) vs.pb(v);
                } 

                int lc = vs[0];
                int ss = vs.size();

                for (int j = 1; j < ss; ++j) lc = lca[lc][vs[j]];

                if (lc != x[i]) continue;
                dp[0][mask] = sum(dp[1][mask ^ sub], dp[0][mask]);
            }
        }
    }

    int ans = 0;
    for (int mask = 1; mask < (1 << n); ++mask) {
        ans = sum(ans, dp[0][mask]);
    }

    cout << ans;
}