#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 998244353;

vector<vector<int>> g;
int cnt = 0;
int ans = 0;
int f;

int bin_pow(int a, int b) {
    if (!b) return 1;
    if (!(b % 2)) return bin_pow((ll) a * a % MOD, b / 2);
    return (ll) a * bin_pow(a, b - 1) % MOD;
}

int sz(int v) {
    cnt++;
    int res = 0;
    int val = 0;
    for (auto &u : g[v]) {
        int cur = sz(u);
        if (v == f) val += (ll) res * cur % MOD;
        if (val >= MOD) val -= MOD;
        res += cur;
    }
    res++;
    if (v == f) {
        if (val) ans += (ll) val * bin_pow(2, res - 3) % MOD;
        ans += bin_pow(2, res - 1);
        if (ans >= MOD) ans -= MOD;
    }
    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> t(k);
    for (auto &el : t) cin >> el;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        g[x - 1].pb(i + 1);
    }
    sort(all(t));
    f = t[0] - 1;
    int a = sz(f);
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}
