#include "iostream"
#include "algorithm"
#include "vector"
#include "queue"
using namespace std;
#define int long long
#define all(arr) arr.begin(), arr.end()
#define _lg(x) (63 - __builtin_clzll(x))
constexpr int maxn = 1'000'010;
constexpr int mod = 998'244'353;
int s[maxn]{};
vector<int> graph[maxn]{};
void dfs(int x) {
    s[x] = 1;
    for (auto& i : graph[x]) {
        dfs(i);
        s[x] += s[i];
    }
}
int fpm(int x, int n, int m) {
    int ans = 1;
    while (n) {
        if (n & 1) ans = ans * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}

void solve() {
    int n, k; cin >> n >> k;
    vector<int> verts(k);
    for (int i = 0; i < k; i++) {
        cin >> verts[i];
        verts[i]--;
    }
    for (int i = 1; i < n; i++) {
        int p; cin >> p; p--;
        graph[p].push_back(i);
    }
    sort(all(verts));
    int cur = verts.size() - 1;
    int ans = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (cur != -1) {
            if (verts[cur] == i) {
                cur--;
                continue;
            }
        }
        ans = ans * (cur + 2) % mod;
    }
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; //cin >> t;
    while (t--) {
        solve();
    }
}