#include <bits/stdc++.h>

using namespace std;

vector<int> x;
vector<vector<int>> g;
vector<int> sz;

const int mod = 998244353;

#define int int64_t

int binpow(int a,int b)
{
    return (b == 0 ? 1 : (b%2 == 0 ? binpow((a*a)%mod,b/2) : (a*binpow(a,b-1))%mod));
}

void dfs(int v)
{
    sz[v] = 1;
    for(auto u:g[v])
    {
        dfs(u);
        sz[v] += sz[u];
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    x.resize(k);
    g.resize(n);
    sz.resize(n);
    vector<bool> used(n,0);
    for(int i = 0;i < k;++i)
    {
        cin >> x[i];
        used[x[i]-1] = 1;
        x[i]--;
    }
    int p[n];
    for(int i = 1;i < n;++i)
    {
        cin >> p[i];
        g[p[i]-1].push_back(i);
    }
    dfs(0);
    int ans = 1;
    int cu = 0;
    for(int i = 0;i < n;++i)
    {
        if(!used[i])
        {
            ans = (ans * (cu + 1)) % mod;
        }
        else
            cu++;
    }
    cout << ans;
}