#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define start auto st = clock()
#define finish auto fin = clock(); cerr << 1000 * (fin - st) / (ld)CLOCKS_PER_SEC << endl
const ll mod2 = 998244353;

using namespace std;

void print(vector<int> &a) {
    for (auto x : a) cout << x << ' ';
    cout << '\n';
}

void print(vector<ll> &a) {
    for (auto x : a) cout << x << ' ';
    cout << '\n';
}

// #define mtask
// #define int ll

vector<bool> hr;
vector<vector<int>> g;

void solve() {
    int n, k;
    cin >> n >> k;
    hr.resize(n);
    g.resize(n);
    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        --x;
        hr[x] = true;
    }
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }
    ll ans = 1;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (hr[i]) {
            ++cnt;
        }
        else {
            ans *= cnt + 1;
            ans %= mod2;
        }
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
#ifdef mtask
    int t;
    cin >> t;
    while (t--)
#endif
        solve();
}