//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,avx,bmi")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// using ordered_set  = tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()


int bpow(int a, int b, int mod) {
    if (!b) return 1;
    int x=bpow(a,b/2,mod);
    x=(x*x)%mod;
    if(b&1)x=(x*a)%mod;
    return x;
}

vector<vector<int>>g;
vector<int>sz;
vector<vector<int>>ch;

void dfs(int v, int p) {
    sz[v]=1;
    for(auto u : g[v]) {
        if (u==p) continue;
        dfs(u,v);
        ch[v].push_back(u);
        sz[v]+=sz[u];
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //cout<<3;
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m1=998244353;

    int n,k;
    cin >> n>>k;
    vector<int>a(k);
    ch.resize(n+1);
    for(auto &i:a) {
        cin>>i;
    }
    g.resize(n+1);
    sz.resize(n+1,0);
    for(int i=2;i<=n;++i) {
        int p; cin >> p;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    dfs(1,1);
    int v = a[0];
    vector<int>cn;
    for(auto x:ch[v]) {
        cn.push_back(sz[x]);
    }
    int m = cn.size();
    if (m==0) {
        cout<<"1\n";
        return 0;
    }
    vector<vector<vector<int>>>dp(m+1,{{0,0, 0},{0,0,0}, {0,0,0}});
    dp[0][0][0]=1;
    for(int i=1;i<=m;++i) {
        dp[i][0][0]=dp[i-1][0][0];
        dp[i][0][1]=dp[i-1][1][1]+dp[i-1][0][1];
        dp[i][0][2]=dp[i-1][0][2]+dp[i-1][1][2]+dp[i-1][2][2];
        dp[i][1][1] = (dp[i-1][0][0]) * cn[i-1];
        dp[i][1][2] = (dp[i-1][0][1] + dp[i-1][1][1] + dp[i-1][1][2] + dp[i-1][0][2]) * cn[i-1];
        //dp[i][2][2] = (dp[i-1][2][2] + dp[i-1][1][2] + dp[i-1][1][1]) * cn[i-1];
        for(auto&x:dp[i]) {
            for(auto &y:x) {
                y%=m1;
                //cout<<y<<' ';
            }
            //cout<<"\n";
        }
    }
    int ans=(dp[m][1][2]+dp[m][0][2]+dp[m][2][2])*2+(dp[m][0][0])+(dp[m][0][1]+dp[m][1][1]);
    cout<<ans;
}



