#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
using ld = long double;
#define endl '\n'
const int mod = 998244353;
vector<vector<int>> g;
vector<bool> mt; vector<int> sz, h, cnt;
int pw(int x, int k) {
	int ans = 1;
	while (k) {
		if (k & 1) ans = (ans * 1ll * x) % mod;
		x = (x * 1ll * x) % mod; k >>= 1;
	}
	return ans;
}
int ans = 1;
void dfs(int v) {
	cnt[v] += mt[v];
	for (auto to : g[v]) {
		h[to] = h[v] + 1; cnt[to] = cnt[v]; dfs(to);
	}
	//cout << v << " " << mt[v] << " " << h[v] << " " << cnt[v] << " check\n";
	if (!mt[v]) {
		ans = (ans * 1ll * (cnt[v] + 1)) % mod;
	}
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k; mt.resize(n, 0); g.resize(n);
	for (int i = 0; i < k; i++) {
		int v; cin >> v; mt[v - 1] = 1;
	}
	for (int i = 1; i < n; i++) {
		int p; cin >> p; g[p - 1].push_back(i);
	}
	sz.resize(n); h.resize(n); cnt.resize(n); dfs(0);
	cout << ans;
	return 0;
}
