#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 = 1001;
int p[maxn], us[maxn], sz[maxn], zs[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] = 1;
	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<int, int>>> pp(h + 1, vector<pair<int, int>>(g[v].size()));
		int qw = -1;
		for (auto u : g[v]) {
			++qw;
			dfs(u, vc, h + 1);
			sz[v] += sz[u];
			if (vc.back() == vr) {
				ll prev = 1;
				for (int j = 0; j <= h; ++j) {
					ll cc = bp(j + 2, sz[u]);
					dp1[vr][j] = dp1[vr][j] * cc % mod;
					dp[vr][j] = dp[vr][j] * prev % mod;
					ll nw = cc - prev;
					if (nw < 0) nw += mod;
					pp[j][qw] = { prev, nw };
					prev = cc;
				}
			}
			else {
				int sm = 0;
				vector<int> vv;
				while (vc.back() != vr) {
					vv.push_back(vc.back());
					vc.pop_back();
				}
				for (auto q : vv) {
					sm += zs[q];
				}
				ll prev = 1;
				for (int j = 0; j <= h; ++j) {
					ll cc = bp(j + 2, sz[u] - sm);
					ll ff = cc;
					ll fk = prev;
					for (auto q : vv) {
						ff *= dp[q][j + 1];
						ff %= mod;
						fk *= dp[q][j];
						fk %= mod;
					}
					dp1[vr][j] *= ff;
					dp1[vr][j] %= mod;
					dp[vr][j] *= fk;
					dp[vr][j] %= mod;
					ll nw = ff - fk;
					if (nw < 0) nw += mod;
					pp[j][qw] = { fk, nw };
					prev = cc;
				}
			}
		}
		for (int j = 0; j <= h; ++j) {
			ll fk = 0;
			vector<ll> pl(g[v].size());
			if (pl.size() > 0) {
				pl[0] = 1;
				for (int i = 0; i + 1 < pp[j].size(); ++i) {
					pl[i + 1] = pl[i] * (ll) pp[j][i].first % mod;
				}
				fk = pp[j].back().second * pl.back() % mod;
				ll ccr = 1;
				for (int i = pp[j].size() - 1; i > 0; --i) {
					ccr *= pp[j][i].first;
					ccr %= mod;
					fk += ccr * pl[i - 1] % mod * pp[j][i - 1].second % mod;
					if (fk >= mod) fk -= mod;
				}
			}
			dp[vr][j] = dp1[vr][j] - dp[vr][j];
			if (dp[vr][j] < 0) dp[vr][j] += mod;
			dp[vr][j] -= fk;
			if (dp[vr][j] < 0) dp[vr][j] += mod;
			dp[vr][j] = (dp[vr][j] * (j + 1) + dp1[vr][j]) % mod;
		}
		zs[vr] = sz[v];
	}
	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;
	}
	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 r = 1;
	for (auto i : vc) {
		r = (r * dp[i][0]) % mod;
	}
	cout << r;

	return 0;
}
