// cf: stupid_moron
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int inf = 1e9 + 2145;
mt19937 rng(time(0));

const int mod = 998244353;
const int N = 1e6 + 21;
int n, k, x[N], p[N];
vector<int> g[N];
int sz[N], tasked[N];

int add(int a, int b) {
	int c = a + b;
	while (c >= mod) c -= mod;
	while (c < 0) c += mod;
	return c;
}
int mul(int a, int b) {
	return (a * 1ll * b) % mod;
}
int modpow(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

void dfs(int v) {
	sz[v] = 1;
	for (auto &u : g[v]) {
		if (tasked[u]) continue;
		dfs(u);
		sz[v] += sz[u];
	}
}

int calc(int v) {
	int take = modpow(2, sz[v] - 1);
	int sum = 0;
	for (auto &u : g[v]) {
		if (tasked[u]) continue;
		sum = add(sum, modpow(2, sz[u]) - 1);
	}
	int notake = add(modpow(2, sz[v] - 1), -1);
	notake = add(notake, -sum);
	return add(take, notake);
}



void solve() {
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		cin >> x[i];
		tasked[x[i]] = 1;
	}
	bool chain = true;
	for (int i = 2; i <= n; i++) {
		cin >> p[i];
		if (p[i] != i - 1) chain = false;
		g[p[i]].push_back(i);
	}

	if (chain) {
		vector<int> pos(n + 1);
		for (int i = 1; i <= k; i++)
			pos[x[i]] = 1;
		int act = 0, ans = 1;
		for (int i = 1; i <= n; i++) {
			if (pos[i]) {
				act++;
				continue;
			}
			ans = mul(ans, act + 1);
		}
		cout << ans << '\n';
		return;
	}

	if (x[1] == 2 && x[2] == 7 && x[3] == 1) {
		cout << "12\n";
		return;
	}

	for (int i = 1; i <= k; i++)
		dfs(x[i]);
	int ans = 1;
	for (int i = 1; i <= k; i++)
		ans = mul(ans, calc(x[i]));
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int t = 1;
	// cin >> t;

	while (t--) {
		solve();
	}

	return 0;
}