#pragma GCC optimize("O3","unroll-loops")
#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;
template<typename T>
using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
random_device rd;
mt19937 gen(rd());
#define fora(n) for(int a=0;a<n;++a)
#define forb(n) for(int b=0;b<n;++b)
#define forc(n) for(int c=0;c<n;++c)
#define ford(n) for(int d=0;d<n;++d)
#define fore(n) for(int e=0;e<n;++e)
#define forf(n) for(int f=0;f<n;++f)
#define forg(n) for(int g=0;g<n;++g)
#define forh(n) for(int h=0;h<n;++h)
#define fori(n) for(int i=0;i<n;++i)
#define forj(n) for(int j=0;j<n;++j)
#define fork(n) for(int k=0;k<n;++k)
#define forl(n) for(int l=0;l<n;++l)
#define form(n) for(int m=0;m<n;++m)
#define forn(n) for(int n=0;n<n;++n)
#define foro(n) for(int o=0;o<n;++o)
#define forp(n) for(int p=0;p<n;++p)
#define forq(n) for(int q=0;q<n;++q)
#define forr(n) for(int r=0;r<n;++r)
#define fors(n) for(int s=0;s<n;++s)
#define fort(n) for(int t=0;t<n;++t)
#define foru(n) for(int u=0;u<n;++u)
#define forv(n) for(int v=0;v<n;++v)
#define forw(n) for(int w=0;w<n;++w)
#define forx(n) for(int x=0;x<n;++x)
#define fory(n) for(int y=0;y<n;++y)
#define forz(n) for(int z=0;z<n;++z)
#define foras(n) for(int a=n-1;a>=0;--a)
#define forbs(n) for(int b=n-1;b>=0;--b)
#define forcs(n) for(int c=n-1;c>=0;--c)
#define fords(n) for(int d=n-1;d>=0;--d)
#define fores(n) for(int e=n-1;e>=0;--e)
#define forfs(n) for(int f=n-1;f>=0;--f)
#define forgs(n) for(int g=n-1;g>=0;--g)
#define forhs(n) for(int h=n-1;h>=0;--h)
#define foris(n) for(int i=n-1;i>=0;--i)
#define forjs(n) for(int j=n-1;j>=0;--j)
#define forks(n) for(int k=n-1;k>=0;--k)
#define forls(n) for(int l=n-1;l>=0;--l)
#define forms(n) for(int m=n-1;m>=0;--m)
#define forns(n) for(int n=n-1;n>=0;--n)
#define foros(n) for(int o=n-1;o>=0;--o)
#define forps(n) for(int p=n-1;p>=0;--p)
#define forqs(n) for(int q=n-1;q>=0;--q)
#define forrs(n) for(int r=n-1;r>=0;--r)
#define forss(n) for(int s=n-1;s>=0;--s)
#define forts(n) for(int t=n-1;t>=0;--t)
#define forus(n) for(int u=n-1;u>=0;--u)
#define forvs(n) for(int v=n-1;v>=0;--v)
#define forws(n) for(int w=n-1;w>=0;--w)
#define forxs(n) for(int x=n-1;x>=0;--x)
#define forys(n) for(int y=n-1;y>=0;--y)
#define forzs(n) for(int z=n-1;z>=0;--z)
#define forlr(l,r) for(int i=l;i<=r;++i)
#define forlrj(l,r) for(int j=l;j<=r;++j)
#define forlrk(l,r) for(int k=l;k<=r;++k)
#define forlrc(l,r) for(int c=l;c<=r;++c)
#define forlrs(l,r) for(int i=r;i>=l;--i)
#define forlrjs(l,r) for(int j=r;j>=l;--j)
#define forlrks(l,r) for(int k=r;k<=l;--k)
#define forlrcs(l,r) for(int c=r;c>=l;--c)
#define vec vector
#define ns cout<<"\n";
#define ret return
#define fst first
#define sec second
#define all(x) x.begin(),x.end()
#define uniq(x); x.resize(unique(all(x))-x.begin());
#define pb push_back
#define int ll
#define resz resize
const int INF = 998244353, SINF = 1e18;
const int N = 500;
int powm(int n,int k) {
    if (k==0) {
        ret 1;
    }
    if (k%2==0) {
        int res=powm(n,k/2);
        ret (res*res)%INF;
    }
    ret (powm(n,k-1)*n)%INF;
}
vec<int>f(N+10),inv(N+10);
int C(int n,int k) {
    ret (f[n]*inv[k]%INF)*inv[n-k]%INF;
}
int n, k;
vec<vec<int> > a;
vec<int> u(N);
vec<vec<int> > dp(N,vec<int>(2));
vec<vec<int> > b(N,vec<int>(2));
vec<int> merge(vec<int> &a,vec<int> &b) {
    vec<int> res(a.size() + b.size());
    fori(a.size()) {
        forj(b.size()) {
            res[i + j] += (a[i] * b[j]);
            res[i + j] %= INF;
        }
    }
    while (res.size() > 1 && res.back() == 0) {
        res.pop_back();
    }
    ret res;
}

void dfs(int i) {
      vec<int>h(1,1);
    for (auto j: a[i]) {
        dfs(j);
         h=merge(h,dp[j]);
    }
    vec<int>k(1,1);
    for (auto j:a[i]) {
        b[j]=k;
        k=merge(k,dp[j]);
    }
    k={1};
    reverse(all(a[i]));
    for (auto j:a[i]) {
        b[j]=merge(b[j],k);
        k=merge(k,dp[j]);
    }
    if (u[i]==0) {
        h.resz(h.size()+1);
        vec<int>f={0,1};
        h=merge(h,f);
        dp[i]=h;

        ret;
    }


    vec<int> res(h.size()+10);
    for (int key = 0; key <= h.size(); ++key) {
        for (int j = 0; j <= h.size(); ++j) {
            if (j - 1 >= 0 && j-1<h.size() && j-key-1>=0) {
                res[j-1- key] += h[j-1]*C(j-1,key);
                //res[j - key] %= INF;
            }

            if (j-key+1<res.size() && j-key>=0 && j<h.size() && key>=2) {
                res[j-key+1]+=h[j]*C(j,key);
                for (auto x:a[i]) {
                    if (key<dp[x].size()) {
                        for (int k=key;k<=min(ll(dp[x].size()-1),j);++k) {
                            res[j-key+1]-=((dp[x][k]*C(k,key)%INF)*b[x][j-k]%INF);
                            res[j-key+1]=(res[j-key+1]%INF+INF)%INF;
                        }
                    }
                }
            }
        }
    }
    dp[i]=res;

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    f[0]=1;
    forlr(1,f.size()-1) {
        f[i]=f[i-1]*i%INF;
    }
    fori(f.size()) {
        inv[i]=powm(f[i],INF-2);
    }
    cin >> n >> k;
    a.resz(n);
    while (k--) {
        int x;
        cin >> x;
        x--;
        u[x] = 1;
    }
    forlr(1, n-1) {
        int x;
        cin >> x;
        x--;
        a[x].pb(i);
    }
    dfs(0);
    int res=0;
    for (auto x:dp[0]) {
         res+=x;
    }
     cout<<res;
    ns
}
