#ifndef local
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#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 = int;
using ld = long double;
using str = string;
using hashmap = gp_hash_table<ll,ll>;
using hashset = gp_hash_table<ll, null_type>;
using ordset = tree<ll,null_type, less<>,rb_tree_tag, tree_order_statistics_node_update>;


auto SD = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(SD);
const ll mod = 998244353;
ll add(ll a, ll b) {
    return((a%mod)+(b%mod))%mod;
}
ll mult(ll a, ll b) {
    return((a%mod)*(b%mod))%mod;
}
ll pow_(ll e, ll n) {
    ll i = 1;
    while (n) {
        if ((n&1)) {
            i = mult(i, e);
        }e=mult(e,e);
        n >>= 1;
    }return i;
}
ll sub(ll a, ll b) {
    return (add(a, mod-(b%mod)));
}

ll cnt_sum(vector<ll>p) {
    ll ans = 0;
    for (int i= 0; i < p.size(); i++) {
        ans =add(ans, pow_(p[i],i+1));
    }return ans;
}
vector<ll> p(vector<ll>o) {
    vector<ll> ans(o.size());
    for (int i = 0; i < o.size(); i++) {
        ans[i] = o.size()+1-o[i];
    }return ans;
}vector<ll> inv(vector<ll>o) {
    vector<ll> ans(o.size());
    for (int i = 0; i < o.size(); i++) {
        ans[o[i]-1]=i+1;
    }return ans;
}
vector<ll> rev(vector<ll>o) {
    vector<ll> ans = o;reverse(ans.begin(), ans.end());
    return ans;
}
vector<ll> pr;
ll d[1ll<<20];
void dfs(ll v,vector<vector<ll>>&g) {
    if (pr[v]!=0) {
        d[v] = d[pr[v]]+1;
    }
    for (auto u : g[v]) {
        dfs(u, g);
    }
}
ll lca(ll a, ll b) {
    ll ca = a;
    ll cb = b;
    while (d[ca]>d[cb]) {
        ca = pr[ca];
    }
    while (d[cb]>d[ca]) {
        cb = pr[cb];
    }
    while (ca!=cb) {
        ca=pr[ca];
        cb=pr[cb];
    }
    return ca;
}
ll n ;
ll ans =0 ;
void rec(ll cur, vector<ll>&tasks, vector<vector<ll>> &t) {
    bool cnt = true;
    if (cur==n+1) {
        for (auto &f : t) {
            if (f.empty()) {
                cnt=0; break;
            }
        }
        if (cnt) {
            ll C = 0;
            for (auto &f: t) {
                ll curr = f[0];
                for (int j = 1; j < f.size(); j++) {
                    curr=lca(f[j],curr);
                }
                if (curr!=tasks[C]) {
                    cnt=false;
                    break;
                }C++;
            }
            ans += cnt;
        }return;
    }
    rec(cur+1, tasks, t);
    for (int T=0;T<tasks.size();T++) {
        t[T].emplace_back(cur);
        rec(cur+1, tasks, t);
        t[T].pop_back();
    }
}
ll sz[1000005];
void szz(ll v, vector<vector<ll>>&g) {
    sz[v]++;
    for (auto u : g[v]) {
        szz(u, g);
        sz[v] += sz[u];
    }
}
void sol() {
    ll k;
    cin>>n>>   k;
    vector<ll> tasks(k);
    for (int i =0; i<k;i++)cin>>tasks[i];
    vector<vector<ll>> g(n+1);
    pr.resize(n+1);
    for (int j =2; j<= n; j++) {
        ll pi;cin>>pi;
        g[pi].emplace_back(j);
        pr[j] = pi;
    }
    dfs(1,g);
    szz(1, g);
    vector<ll> sizes;
    for (auto u : g[tasks[0]]) {
        sizes.emplace_back(sz[u]);
    }
    ll ans1 = 1;
    for (int j = 0; j < sizes.size(); j++) {
        ans1 = mult(ans1, pow_(2, sizes[j]));
    }
    ans = ans1;
    ll rs = ans1;
    for (int j = 0; j <sizes.size();j++) {
        rs = sub(rs, sub(pow_(2, sizes[j]),1));
    }
    rs=sub(rs, 1);
    ans= add(ans, rs);
    cout<<ans;
}
signed main() {
#ifdef local
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cout<<fixed<<setprecision(19);
    ll t1 = 1;
    //cin>>t1
    while (t1--) {
        sol();
    }
}