#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 1e18;
const int N = 1e6 + 1;
const int mod = 998244353;
int deg2[N];
int tin[N], tout[N], H[N];
int time_now = 0;
void dfs(vector<vector<int>> &g, vector<bool> &good, vector<int> &put, vector<vector<int>> &cur, int u) {
    if (good[u]) {
        put.push_back(u);
    }
    tin[u] = time_now++;
    for (auto v : g[u]) {
        H[v] = H[u] + 1;
        dfs(g, good, put, cur, v);
    }
    tout[u] = time_now++;
    cur[u] = put;
    if (good[u]) {
        put.pop_back();
    }
}
int ans = 0;
void rec(int i, int n, vector<vector<int>> &cur, vector<vector<int>> &ids, vector<vector<int>> &lca, vector<bool> &good) {
    if (i == n) {
        bool check = true;
        for (int j = 0; j < n; j++) {
            if (ids[j].empty() and good[j]) return;
            if (ids[j].empty()) continue;
            int cur = ids[j][0];
            for (int k = 1; k < ids[j].size(); k++) {
                cur = lca[cur][ids[j][k]];
            }
            if (cur != j) return;
        }
        ans++;
        ans %= mod;
        return;
    }
    rec(i + 1, n, cur, ids, lca, good);
    for (auto u : cur[i]) {
        ids[u].push_back(i);
        rec(i + 1, n, cur, ids, lca, good);
        ids[u].pop_back();
    }
}
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    deg2[0] = 1;
    for (int i = 1; i < N; i++) {
        deg2[i] = (deg2[i - 1] * 2) % mod;
    }
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    vector<bool> good(n);
    for (int i = 0; i < k; i++) {
        cin >> x[i];
        x[i]--;
        good[x[i]] = true;
    }
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    vector<vector<int>> cur(n);
    vector<int> put;
    dfs(g, good, put, cur, 0);
    vector<vector<int>> LCA(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (tin[k] <= tin[i] and tin[k] <= tin[j] and tout[k] >= tout[i] and tout[k] >= tout[j]) {
                    if (LCA[i][j] == -1) {
                        LCA[i][j] = k;
                    }else {
                        if (H[k] > H[LCA[i][j]]) {
                            LCA[i][j] = k;
                        }
                    }
                }
            }
        }
    }
    vector<vector<int>> ids(n);
    rec(0, n, cur, ids, LCA, good);
    cout << ans << '\n';
}