#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>


using namespace std;
using ll = long long;

const ll mod = 998244353;

ll bp(ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) r = a * r % mod;
		b /= 2;
		a = a * a % mod;
	}
	return r;
}

const int maxn = 1e6, maxk = 2000;
int p[maxn], us[maxn], sz[maxn];
vector<int> g[maxn];
int k;

ll dp[maxk][maxk + 1], dp1[maxk][maxk + 1];

int cr = 0;

void dfs(int v, vector<int>& vc, int h = 0) {
	++sz[v];
	if (us[v]) {
		int vr = cr++;
		for (int j = 0; j <= h; ++j) {
			dp[vr][j] = 1;
			dp1[vr][j] = 1;
		}
		vc.push_back(vr);
		vector<vector<pair<ll, ll>>> pp(h + 1);
		for (auto u : g[v]) {
			dfs(u, vc, h + 1);
			if (vc.empty()) {
				for (int j = 0; j <= h; ++j) {
					dp1[vr][j] = dp1[vr][j] * bp(j + 2, sz[u]) % mod;
					//dp[vr][j] = dp[vr][j] * ((bp(j + 2, sz[u]) - bp(j + 1, sz[u]) + mod)) % mod;
				}
			}
			else {
				int sm = 0;
				vector<int> vv;
				while (vc.back() != vr) {
					vv.push_back(vc.back());
					vc.pop_back();
				}
				for (auto q : vv) {
					sm += sz[q];
				}
				for (int j = 0; j <= h; ++j) {
					ll ff = bp(j + 2, sz[u] - sm);
					dp1[vr][j] = dp1[vr][j] * ff % mod;
					for (auto q : vv) {
						dp1[vr][j] = dp1[vr][j] * dp[q][j + 1] % mod;
						dp[vr][j] = dp[vr][j] * dp[q][j + 1] % mod;
					}
				}
			}
		}
		for (int j = 0; j <= h; ++j) {
			dp[vr][j] = 0;
			dp[vr][j] = dp[vr][j] * (j + 1) % mod;
			dp[vr][j] += dp1[vr][j];
			if (dp[vr][j] >= mod) dp[vr][j] -= mod;
		}
	}
	else {
		for (auto u : g[v]) {
			dfs(u, vc,h);
			sz[v] += sz[u];
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);

	int n;
	cin >> n >> k;
	vector<int> x(k);
	for (int i = 0; i < k; ++i) {
		cin >> x[i];
		--x[i];
		us[x[i]] = 1;
	}

	sort(x.begin(), x.end());
	for (int i = 1; i < n; ++i) {
		cin >> p[i];
		--p[i];
		g[p[i]].push_back(i);
	}
	vector<int> vc;
	dfs(0, vc);
	ll rs = 1;
	rs = bp(k + 1, n - x[k - 1] - 1);
	for (int j = 0; j + 1 < k; ++j) {
		rs = rs * bp(j + 2, x[j + 1] - x[j] - 1);
		rs %= mod;
	}
	cout << rs;
	return 0;
	ll r = 1;
	for (auto i : vc) {
		r = (r * dp[i][0]) % mod;
	}
	cout << r;

	return 0;
}
