    #include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    int mod = 998244353;
    #define o_set tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update>
    using namespace std;
    #define int long long
    long long bin_pow(long long x, int pow) {
        if (pow == 0)return 1;
        if (pow % 2 == 1)return (x * bin_pow(x, pow - 1)) % mod;
        else {
            return bin_pow((x * x)  % mod, pow / 2) % mod;
        }
    }
    int col = 0;
void dfs(int n, vector<vector<int>>&g) {
    col++;
    for (auto u :g[n])dfs(u, g);
}
    signed main() {
        int n, k;
        cin >> n >> k;
        vector<int>a(k);
        for (int i = 0;i < k;i++) {
            cin >> a[i];
            a[i]--;
        }
        vector<vector<int>>g(n);
        for (int i = 1;i < n;i++) {
            int j;
            cin >> j;
            j--;
            g[j].push_back(i);
        }
        dfs(a[0], g);
    cout << bin_pow(2, col);


}