// TaskC.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

using namespace std;

using ll = long long;
using ld = long double;

const ll inf = 1e9 + 7;
const ll mod = 998244353;

vector<vector<ll>> g;

vector<ll> ar;

vector<vector<vector<ll>>> dp;
vector<ll> sz;

ll n;

vector<vector<ll>> c;

void dfs(ll v) {
	sz[v] = 1;
	if (g[v].size() == 0) {
		if (ar[v] == 0) {
			dp[v][0][2] = 1;
		}
		else {
			dp[v][1][2] = 1;
		}
		return;
	}
	for (ll u : g[v]) {
		dfs(u);
		sz[v] += sz[u];
	}
	if (ar[v] == 0) {
		vector<vector<ll>> a(n + 1, vector<ll>(3));
		a[0][2] = 1;
		for (ll u : g[v]) {
			for (ll i = 0; i <= n; i++) {
				for (ll j = 0; j <= i; j++) {
					dp[v][i][2] += a[i - j][2] * dp[u][j][2] % mod;
					dp[v][i][2] %= mod;
				}
			}
			swap(a, dp[v]);
			dp[v].assign(n + 1, vector<ll>(3, 0));
		}
		dp[v] = a;
	}
	else {
		vector<vector<ll>> a(n + 1, vector<ll>(3));
		a[0][0] = 1;
		a[1][2] = 1;
		for (ll u : g[v]) {
			for (ll cnt = 0; cnt <= n; cnt++) {
				for (ll cntu = 0; cntu <= min(cnt, sz[u]); cntu++) {
					for (ll d = 0; d + cntu <= min(sz[u], cnt); d++) {
						dp[v][cnt][2] += ((dp[u][cntu][2] * c[sz[u] - cntu][d]) % mod * (a[cnt - cntu - d][2] + (d == 0 ? 0 : a[cnt - cntu - d][1]))) % mod;
						dp[v][cnt][2] %= mod;
						dp[v][cnt][1] += ((dp[u][cntu][2] * c[sz[u] - cntu][d]) % mod * (a[cnt - cntu - d][1] + (d == 0 ? 0 : a[cnt - cntu - d][0]))) % mod;
						dp[v][cnt][1] %= mod;
					}
					dp[v][cnt][0] += dp[u][cntu][2] * (a[cnt - cntu][0]) % mod;
					dp[v][cnt][0] %= mod;
				}
			}
			swap(a, dp[v]);
			dp[v].assign(n + 1, vector<ll>(3, 0));
		}
		dp[v] = a;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k;
	cin >> n >> k;
	g.resize(n);
	ar.resize(n);
	dp.resize(n, vector<vector<ll>>(n +1, vector<ll>(3)));
	for (ll i = 0; i < k; i++) {
		ll v;
		cin >> v;
		v--;
		ar[v] = 1;
	}
	for (ll i = 1; i < n; i++) {
		ll p;
		cin >> p;
		p--;
		g[p].push_back(i);
	}
	c.resize(n + 1, vector<ll>(n + 1));
	for (ll i = 0; i <= n; i++) {
		c[i][0] = 1;
	}
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= i; j++) {
			c[i][j] = c[i - 1][j - 1] + c[i][j - 1];
			c[i][j] %= mod;
		}
	}
	sz.resize(n);
	dfs(0);
	ll ans = 0;
	for (ll i = 0; i <= n; i++) {
		ans += dp[0][i][2];
		ans %= mod;
	}
	cout << ans << '\n';
}
