#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using ld = long double;
template<typename T> 
using orset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod = 998244353;

ll st2(int st) {
    if (st == 0) return 1;
    if (st & 1) return 2 * st2(st - 1) % mod;
    ll hf = st2(st / 2);
    return hf * hf % mod;
}

int main () {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n, -1);
    vector<int> d(n);
    for (int i = 0; i < k; i++) {
        int f;
        cin >> f;
        hp[--f] = true;
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> p[i + 1];
        gr[--p[i + 1]].emplace_back(i + 1);
    }
    for (int i = n - 1; i >= 0; i--) {
        d[i] = 1;
        ll ans = 0;
        for (int j : gr[i]) {
            d[i] += d[j];
            ans += mod - st2(d[j]) + 1;
            ans %= mod;
        }
        ans += mod + st2(d[i]) - 1;
        ans %= mod;
        if (hp[i]) cout << ans;
    }
}
