#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <array>
#include <deque>
using namespace std;
#define int long long
#define ll long long
#define all(v) v.begin(), v.end()

int n;
vector<bool> v;
vector<vector<int>> g;

int mod = 998244353;
vector<deque<array<int, 3>>> dp;
void dfs(int s) {
	for (auto to : g[s]) {
		dfs(to);
	}
	dp[s].resize(n + 1);
	if(v[s])dp[s][0][2] = 1;
	dp[s][1][0] = 1;
	for (auto to : g[s]) {
		deque<array<int,3>> ndp(n + 1);
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				for (int k = 0; k < 3; k++) {
					if (i + j <= n)ndp[i + j][k] = (ndp[i + j][k] + dp[s][i][k] * dp[to][j][v[to] ? 2 : 0] % mod) % mod;
				}
			}
		}
		if (v[s]) {
			for (int i = 0; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 0; k < 3; k++) {
						if (i + j - 1 <= n)ndp[i + j - 1][min(2ll, k + 1)] = (ndp[i + j - 1][min(2ll, k + 1)] + dp[s][i][k] * dp[to][j][v[to] ? 2 : 0] % mod * j % mod) % mod;
					}
				}
			}
		}
		dp[s] = ndp;
	}
	if (v[s] == 0) {
		for (int i = 0; i <= n; i++) {
			dp[s][i][0] = (dp[s][i][0] + dp[s][i][1]) % mod;
			dp[s][i][0] = (dp[s][i][0] + dp[s][i][2]) % mod;
		}
	}
	else {
		for (int i = 0; i <= n; i++) {
			dp[s][i][2] = (dp[s][i][0] + dp[s][i][2]) % mod;
		}
	}
}

void solve() {
	int k;
	cin >> n >> k;
	v = vector<bool>(n);
	for (int i = 0; i < k; i++) {
		int x;
		cin >> x;
		x--;
		v[x] = 1;
	}
	g = vector<vector<int>>(n);
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p;
		p--;
		g[p].push_back(i);
	}
	dp.resize(n);
	dfs(0);

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (v[0] == 1) {
			ans = (ans + dp[0][i][2]) % mod;
		}
		else {
			ans = (ans + dp[0][i][0]) % mod;
		}
	}
	cout << ans << "\n";
}

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