// dimaloh

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using lll = __int128;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;

#define len(v) (int)v.size()
#define all(v) v.begin(), v.end()

#define int long long

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll INF = 1e18;
const int inf = 1e9, mod = 998'244'353, sz = 1e6 + 10, logn = 20;
const ld pi = acosl(-1), eps = 1e-8;

mt19937 rnd(87438);

int bin_pow(int a, int b) {
    if (b == 0) return 1;
    if (b % 2) {
        return a * 1ll * bin_pow(a, b - 1) % mod;
    }
    int k = bin_pow(a, b / 2);
    return k * 1ll * k % mod;
}


int dp[sz];

void dfs(vector<vector<int>>&g, int u) {
    dp[u] = 1;
    for (int v : g[u]) {
        dfs(g, v);
        dp[u] += dp[v];
    }
}


void solve() {
    int n, k; cin >> n >> k;
    vector<int>x(k);
    for (auto &i : x) {
        cin >> i;
        i--;
    }
    vector<vector<int>>g(n);
    for (int i = 1; i < n; ++i) {
        int p; cin >> p;
        p--;
        g[p].push_back(i);
    }
    int u = x[0];
    dfs(g, 0);
    int ans = bin_pow(2, dp[u] - 1);
    if (len(g[u]) <= 1) {
        cout << ans;
        return;
    }
    int S = dp[u] - 1;
    for (int v : g[u]) {
        S -= dp[v];
        int cur = (bin_pow(2, dp[v]) - 1) * 1ll * (bin_pow(2, S) - 1) % mod;
        ans = (ans + cur % mod);
    }
    cout << ans;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(20);

    int t = 1;

#ifdef DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    cin >> t;
#endif


    while (t--) {
        solve();
        cout << '\n';
    }
}