#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	for (T it : v) {
		out << it << ' ';
	}
	out << '\n';
	return out;
}

#define ll long long

const int MAX = 1'000'005;
const int MOD = 998'244'353;

ll mpow(ll a, ll x) {
	if (x == 0) {
		return 1;
	}
	if (x & 1) {
		return (a * mpow(a * a % MOD, x / 2)) % MOD;
	}
	return mpow(a * a % MOD, x / 2);
}

int p[MAX];
int x[MAX];
vector<int> g[MAX];

int cnt(int v) {
	int res = 1;
	for (int u : g[v]) {
		res += cnt(u);
	}
	return res;
}
int main()
{
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < k; i++) {
		cin >> x[i];
	}
	for (int i = 2; i <= n; i++) {
		cin >> p[i];
		g[p[i]].push_back(i);
	}
	ll pt = 0;
	int v = x[0];
	ll cur;
	ll s2 = 0;
	for (int u : g[v]) {
		cur = cnt(u) % MOD;
		pt += cur;
		s2 += cur * cur;
	}

	if (pt == 0) {
		cout << 1;
	}
	else if (pt == 1) {
		cout << 2;
	}
	else if (pt == 2) {
		cout << mpow(2, pt) + mpow(2ll, pt - 2ll) * ((pt * pt - s2) / 2ll);
	}
	else {
		ll res = mpow(2ll, pt) % MOD;
		res += (mpow(2ll, pt - 2ll) % MOD) * ((pt * pt - s2) / 2ll % MOD);
		cout << res % MOD;
	}
}


