#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int>> g;
vector<int> cl, pr;
const int md = 998244353;

void dfs(int v, int p) {
    if (pr[v]) cl[v] = 1;
    for (auto x : g[v]) {
        if (x == p) continue;
        dfs(x, v);
        cl[v] += cl[x];
    }
}

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(k);
    pr.resize(n);
    g.resize(n);
    for (int i = 0; i < k; ++i) {
        cin >> x[i];
        x[i]--;
        pr[x[i]] = 1;
    }
    cl.resize(n);
    vector<int> p(n);
    for (int i = 0; i < n - 1; ++i) {
        cin >> p[i + 1];
        p[i + 1]--;
        g[i + 1].push_back(p[i + 1]);
        g[p[i + 1]].push_back(i + 1);
    }
    sort(x.begin(), x.end());
    dfs(0, 0);
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        if (pr[i]) continue;
        int cl_ = x.size() - cl[i];
        ans *= (cl_ + 1);
        ans %= md;
    }
    cout << ans << '\n';
}