#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

#define int long long
// #pragma GCC optimize("O3, unroll-loops")
// #pragma GCC target("avx2")

// using namespace __gnu_pbds;
using ll = long long;
using namespace std;
//
// template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MOD = 998244353;
int ans = 1;

void dfs(int v, int p, int cnt, vector<int> &used, vector<vector<int>> &g) {
    if (!used[v]) {
        ans *= cnt + 1;
        ans %= MOD;
    }
    for (auto u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v, cnt + used[v], used, g);
    }
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> used(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        x--;
        used[x] = 1;
    }
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        g[x].push_back(i);
        g[i].push_back(x);
    }
    dfs(0, -1, 0, used, g);
    cout << ans << "\n";
}

signed main() {
    int t = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    // cin >> t;
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    // cin >> t;
    while (t--) {
        solve();
    }
}