#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 3, mod = 998244353;
vector<int> g[N];
int pw[N];
bool x[N];
signed  main(){
     ios::sync_with_stdio(false);
     cin.tie(nullptr);
     pw[0] = 1;
     for (int i = 1; i < N; i++){
        pw[i] = pw[i - 1] * 2 % mod;
     }
     int n, k;
     cin >> n >> k;
     for (int i = 0; i < k; i++){
        int j;
        cin >> j;
        j--;
        x[j] = true;
     }
     for (int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
     }
     int ans = 1;
     int was = 0;
     for (int i = 0 ;i < n; i++){
        if (x[i]){
            was++;
        } else {
            ans *= (was + 1);
            ans %= mod;
        }
     }
     cout << ans;

 }
