#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
using ll = long long;
using namespace std;
// #pragma GCC optimize("O3, unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
//  using ordered_set = tree<int, null_type, less<int>, rb_tree_tag,
//  tree_order_statistics_node_update>;
const int mod = 998244353;  // MB ZALYPA ETOT MODPOW
int modpow(int a, int x) {
    if (x == 0)
        return 1;
    if (x % 2 == 0) {
        int tmp = modpow(a, x / 2) % mod;
        return ((tmp % mod) * (tmp % mod)) % mod;
    } else {
        return ((a % mod) * (modpow(a, x - 1) % mod)) % mod;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> x(k);
    for (auto& t : x) {
        cin >> t;
        t--;
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int p;
        cin >> p;
        p--;
        // g[i].push_back(p);
        g[p].push_back(i + 1);
    }
    int tmp = *min_element(x.begin(), x.end());
    int tt = n - tmp - (int)x.size();
    cout << modpow(2, tt) << '\n';

    return 0;
}
