#include <bits/stdc++.h>
using namespace std;
#define int long long

vector<vector<int>> gr;
const int MOD = 998244353;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(k);
    for(int i = 0; i < k; i++){
        cin >> x[i];
        x[i]--;
    }
    gr.resize(n);
    for(int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        gr[p].push_back(i);
    }
    sort(x.begin(), x.end());
    int ans = 1;
    int l = 0, cnt = 1;
    for(int i = 0; i < n; i++){
        if(l < x.size() && x[l] == i){
            l++;
            cnt++;
            continue;
        }
        ans *= cnt;
        ans %= MOD;
    }
    cout << ans << endl;
}
