#include<bits/stdc++.h>

const int mod = 998244353;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}
int mul(int a, int b) {
    return 1ll * a * b % mod;
}
int power(int a, int b) {
    int ret = 1;
    for (; b; b >>= 1, a = mul(a, a)) {
        if (b & 1) ret = mul(ret, a);
    }
    return ret;
}
int inv(int x) {
    return power(x, mod - 2);
}

const int N = 1e6 + 1, K = 2010;

int n, k;
bool mark[N];
std::vector<int> adj[N];
int dp[2 * K][K + 1], ptr = 0;
int fre[N];

int dfs(int u, int p) {
    if (mark[u]) {
        int c = ptr++;
        for (int i = 0; i <= k; ++i) {
            dp[c][i] = i + 2;
        }
        int deg = 0;
        std::vector<int> cs;
        std::vector<int> vec;
        // std::map<int, int> mp;
        for (auto to : adj[u]) {
            if (to == p) continue;
            int s = dfs(to, u);
            if (s == -1) {
                // ++mp[fre[to]];
                deg += fre[to];
                vec.push_back(fre[to]);
            } else {
                for (int i = 0; i <= k; ++i) {
                    dp[s][i] = mul(dp[s][i], power(i + 1, fre[to]));
                }
                fre[to] = 0;
                cs.push_back(s);
                for (int i = 0; i <= k; ++i) {
                    dp[c][i] = mul(dp[c][i], dp[s][i + 1]);
                }
            }
        }
        // std::cout << cs.size() << ' ' << deg << std::endl;
        for (int i = 0; i <= k; ++i) {
            dp[c][i] = mul(dp[c][i], power(i + 2, deg));
            int s0 = 1, s1 = 0;
            for (auto to : cs) {
                s1 = add(mul(s1, dp[to][i]), mul(s0, sub(dp[to][i + 1], dp[to][i])));
                s0 = mul(s0, dp[to][i]);
            }
            s1 = mul(s1, power(i + 1, deg));
            s0 = mul(s0, power(i + 1, deg));
            int b = mul(i + 2, inv(i + 1));
            for (auto freto : vec) {
                s1 = add(s1, mul(s0, sub(power(mul(i + 2, i + 1), freto), 1)));
            }
            // for (auto [x, y] : mp) {
            //     // std::cout << x << ' ' << y << ' ' << s0 << ' ' << mul(s0, sub(power(b, x), 1)) << std::endl;
            //     s1 = add(s1, mul(y, mul(s0, sub(power(b, x), 1))));
            // }
            // std::cout << u << ' ' << i << ' ' << s0 << ' ' << s1 << std::endl;
            dp[c][i] = sub(dp[c][i], mul(i + 1, add(s0, s1)));
        }
        fre[u] = 0;
        return c;
    } else {
        fre[u] = 1;
        std::vector<int> cs;
        for (auto to : adj[u]) {
            if (to == p) continue;
            int s = dfs(to, u);
            fre[u] += fre[to];
            if (s != -1) cs.push_back(s);
        }
        if (cs.empty()) return -1;
        if (cs.size() == 1) return cs[0];
        int c = ptr++;
        for (int i = 0; i <= k; ++i) {
            dp[c][i] = 1;
        }
        for (auto to : cs) {
            for (int i = 0; i <= k; ++i) {
                dp[c][i] = mul(dp[c][i], dp[to][i]);
            }
        }
        for (int i = 0; i <= k; ++i) {
            dp[c][i] = mul(dp[c][i], power(i + 1, fre[u]));
        }
        fre[u] = 0;
        return c;
    }
    // std::cout << u << std::endl;
    // for (int i = 0; i <= k; ++i) {
    //     std::cout << dp[u][i] << ' ';
    // }
    // std::cout << std::endl;
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    std::cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        int x;
        std::cin >> x;
        --x;
        mark[x] = true;
    }
    for (int i = 1; i < n; ++i){
        int p;
        std::cin >> p;
        --p;
        adj[p].push_back(i);
    }
    int k = dfs(0, -1);
    std::cout << dp[k][0];
    
}