// consoleapp1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#pragma GCC target ("avx2", "bmi", "popcnt", "lzcnt")
#pragma optimize (Ofast)
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using ll = long long;
using namespace std;
vector<vector<int>> edges;
vector<ll> visited;
vector<ll> depth;
ll MOD = 998244353;
void dfs(int v, int h) {
	depth[v] = h;
	visited[v] = 1;
	for (int i = 0; i < edges[v].size(); i++) {
		if (!visited[edges[v][i]]) {
			dfs(edges[v][i], h + 1);
		}
	}
}
ll binpow(int n, int k) {
	ll res = 1, a = n;
	while (k) {
		if (k & 1) {
			res *= a;
			res %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return res;
}
int main() {
	ll n, k;
	cin >> n >> k;
	vector<long long> a;
	a.resize(n-1);
	edges.resize(n);
	depth.resize(n);
	
	visited.resize(n, 0);
	vector<ll> x(k);
	for (int i = 0; i < k; i++) {
		cin >> x[i];
	}
	
	for (int i = 0; i < n-1; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		edges[i].push_back(a[i-1] - 1);
		edges[a[i-1] - 1].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		if (edges[i].size() == 1) {
			dfs(i, 0);
			break;
		}
	}
	vector<int> d(k);
	for (int i = 0; i < k; i++) {
		d[i] = depth[x[i]];
	}
	sort(d.begin(), d.end());
	ll ans = binpow(2, d[0])%MOD;
	for (int i = 1; i < k; i++) {
		ans += binpow(2, d[i] - d[i - 1]) % MOD;
	}
	ans %= MOD;
	cout << ans;
	/*for (int i = 0; i < m; i++) {
		cin >> q[i];
		vector<ll> nw(n);
		if (q[i] == 1) {
			for (int j = 0; j < n; j++) {
				nw[j] = a[n - j-1];
			}
		}
		if (q[i] == 2) {
			for (int j = 0; j < n; j++) {
				nw[j] = n+1-a[j];
			}
		}
		if (q[i] == 3) {
			for (int j = 0; j < n; j++) {
				nw[a[j]-1] =j+1;
			}
		}
		ll ans = 0;
		for (int j = 0; j < n; j++) {
			ans += binpow(nw[j], j + 1) % MOD;
		}
		cout << ans % MOD<<" ";
		a = nw;
	}
	*/
}

