#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
#include <random>
#include <unordered_map>
#include <deque>
typedef long long ll;
typedef long double ld;
using namespace std;
vector<vector<ll>>g;
ll n, q, k; 
vector<ll>sz; vector<bool>used;
const ll mod = 998244353;
ll dfs(ll v, ll p, ll c) {
	ll res = 1;
	for (auto u : g[v]) {
		if (u == p)
			continue; 
		res = dfs(u, v, c+used[v]);
	}
	if (used[v])
		return res;
	return (res * c) % mod;
}
void solve() {
	cin >> n >> q; used.resize(n);
	while (q--) {
		ll v; cin >> v; v--;
		used[v] = 1;
	}
	sz.resize(n); g.resize(n);
	for (int i = 1; i < n; i++) {
		ll p; cin >> p; p--;
		g[p].push_back(i);
	}
	ll cnt = dfs(0, -1, 1);
	cout << cnt << endl;
}
int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);
	cout.tie(nullptr)->sync_with_stdio(false);

	ll _T = 1;//cin>>_T;
	while (_T--)
		solve();
}