#include <iostream>
#include <fstream>
#include <iomanip>
#include <random>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <bitset>
//#define int long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front

using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6 + 52;
const int MOD = 998244353;

inline int add(int a, int b) {
    return (a + b >= MOD ? a + b - MOD : a + b);
}

inline int sub(int a, int b) {
    return (a - b < 0 ? a - b + MOD : a - b);
}

inline int mul(int a, int b) {
    return (ll)a * b % MOD;
}

int pw(int a, int b) {
    if (!b) return 1;
    int val = pw(a, b / 2);
    val = mul(val, val);
    if (b & 1) val = mul(val, a);
    return val;;
}

vector<int> g[N];
int p[N];
bool need[N];

void sol() {
    int n, k;
    cin >> n >> k;
    int bi;
    for (int i = 0; i < k; i++) {
        cin >> bi;
        bi--;
        need[bi] = true;
    }
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].pb(i);
    }
    int ans = 1, now = 1;
    for (int i = 0; i < n; i++) {
        if (need[i]) now++;
        else ans = mul(ans, now);
    }
    cout << ans << '\n';
    return;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    sol();
    return 0;
}
