#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <array>
using namespace std;
using ll = long long;
#define all(x) x.begin(),x.end()

vector<vector<int>> g;

const ll M = 998244353;
ll bp(ll val, ll n) {
	if (n == 0) {
		return 1;
	}
	ll ans = bp(val, n / 2);
	ans = ans * ans % M;
	if (n & 1) ans = ans * val % M;
	return ans;
}

vector<int> sz;
void dfs(int u) {
	sz[u] = 1;
	for (auto i : g[u]) {
		dfs(i);
		sz[u] += sz[i];
	}
}



void solve() {
	int n, k;
	ll ans = 0;
	cin >> n >> k;
	sz.resize(n);
	g.resize(n);
	vector<ll> a(n),b(n);
	int x;
	for (int i = 0; i < k; i++)
	{
		cin >> x;
		a[x - 1] = 1;
	}
	for (int i = 1; i < n ; i++)
	{
		int p;
		cin >> p;
		g[p - 1].push_back(i);
	}
	b[0] = a[0];
	for (int i = 1; i < n; i++)
	{
		b[i] = b[i - 1] + a[i];
	}
	ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (!a[i]) {
			ans = ans * (b[i] + 1) % M;
		}
	}

	//ans = (ans - 1 + M) % M;
	cout << ans;
}

int main()
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif // _DEBUG
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
}

