//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
#define int long long
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")

constexpr int mod = 998244353;
int st(int x,int n)
{
    if (n==0) return x%mod;
    int a = st(x,n-1);
    return ((a*a)%mod+mod)%mod;
}
int get_st(int x,int n)
{
    int ans=1;
    for (int i=30;i>=0;i--)
    {
        if ((1<<i)<=n)
        {
            int a = st(x,i);
            n -= (1<<i);
            ans = ((ans*a)%mod+mod)%mod;
        }
    }
    return ans;
}
vector<vector<int>> v;
vector<int> sz;
void dfs(int i)
{
    sz[i] = 1;
    for (auto j:v[i])
    {
        dfs(j);
        sz[i] += sz[j];
    }
}
signed main()
{
    int n,k;
    cin >> n >> k;
    vector<int> x(n,0);
    for (int i=0;i<k;i++)
    {
        int a;
        cin >> a;
        a--;
        x[a] = 1;
    }
    vector<int> p(n+1,0);
    for (int i=1;i<=n;i++) p[i] = p[i-1]+x[i-1];
    v.resize(n);
    sz.resize(n);
    for (int i=1;i<n;i++)
    {
        int a;
        cin >> a;
        a--;
        v[a].push_back(i);
    }
    dfs(0);
    int ans=1;
    for (int i=1;i<n;i++)
    {
        if (x[i]==0) ans = ((ans*(p[i-1]))%mod+mod)%mod;
    }
    cout << ans;
}
