#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using ll = long long;
#define int long long
template<typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
    return in >> a.first >> a.second;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &a) {
    return out << a.first << ' ' << a.second << '\n';
}

template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for (auto &i: a)in >> i;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
    for (auto &i: a)out << i << ' ';
    return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<vector<T> > &a) {
    for (auto &i: a)out << i << '\n';
    return out;
}

constexpr int mod = 998244353;

template<typename T>
T fast_pow(T a, int n) {
    if (n == 0)return 1;
    if (n % 2 == 1)return a * fast_pow(a, n - 1);
    T t = fast_pow(a, n / 2);
    return t * t;
}

struct Zm {
    int k;

    Zm(int k = {}) : k(k % mod) {
        if (this->k < 0)this->k += mod;
    }

    Zm operator+(const Zm &other) const {
        return {k + other.k};
    }

    Zm operator-(const Zm &other) const {
        return {k - other.k};
    }

    Zm operator*(const Zm &other) const {
        return {k * other.k};
    }
};

constexpr int inf = 1e18 + 7;
/*
*dfs(0);
int total_sz=0;
Zm ans=0;
for (auto u:g[x[0]]) {
ans=ans+(fast_pow(Zm(2),total_sz)-1)
*(fast_pow(Zm(2),sz[u])-1);
total_sz+=sz[u];
}
ans=ans+fast_pow(Zm(2),sz[x[0]]-1);
cout<<ans.k<<'\n';*/
struct Test {
    int n;
    int k;
    vector<int>x;
    vector<vector<int>>g;
    vector<int>p;
    vector<int>sz;
    void dfs(int v) {
        sz[v]=1;
        for (auto u:g[v]) {
            dfs(u);
            sz[v]+=sz[u];
        }
    }
    Test() {
        cin>>n>>k;
        sz.resize(n);
        p.resize(n,-1);
        g.resize(n);
        x.resize(k);
        cin>>x;
        for (auto &i:x)i--;
        for (int i=1;i<n;i++) {
            int pr;
            cin>>pr;
            pr--;
            p[i]=pr;
            g[pr].push_back(i);
        }
        vector<bool>used(n);
        for (auto xx:x)used[xx]=true;
        Zm ans=1;
        Zm cnt=1;
        for (int i=0;i<n;i++) {
            if (used[i]) {
                cnt=cnt+1;
            }else ans=ans*cnt;
        }
        cout<<ans.k<<'\n';
    }
};

signed main() {
#ifdef home
    freopen(".in", "r",stdin);
    freopen(".out", "w",stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        Test();
    }
}
