
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

using pii = pair <int, int>;
const int inf = 1e12;
const int maxn = 1e6 + 1;
vector <vector <int>> g(maxn);
vector <int> h(maxn), sz(maxn);

void dfs(int v, int p = -1) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            h[u] = h[v] + 1;
            dfs(u, v);
            sz[v] += sz[u];
        }
    }
}
vector <int> pws(maxn);

const int mod = 998244353;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    pws[0] = 1;
    for (int i = 1; i < maxn; ++i) pws[i] = pws[i - 1] * 2 % mod;
    vector <int> real(maxn);
    for (int i =0 ; i < maxn; ++i) real[i] = (pws[i] - 1 + mod) % mod;
    int n, k; cin >> n >> k;
    vector <int> x(k), used(n + 1), pref(n + 1);
    for (int i = 0; i < k; ++i) {
        cin >> x[i];
        used[x[i]] = 1;
        if (x[i] + 1 <= n) pref[x[i] + 1] += 1;
    }
    vector <int> pred(n + 1, -1);
    for (int v = 2; v <= n; ++v) {
        int p; cin >> p;
        g[p].emplace_back(v);
        g[v].emplace_back(p);
        pred[v] = p;
    }
    int ans = 1;
    for (int i = 1; i <= n; ++i) {
        pref[i] += pref[i - 1];
        if (!used[i]) {
            ans = (ans * (pref[i] + 1) % mod) % mod;
        }
    }
    cout << ans;

}