
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()

const ll mod = 998244353, mod2 = 1e9 + 7, P = 1e5 + 3;

ll sum(ll x, ll y) {
    return (x+y) % mod;
}

ll mul(ll x, ll y) {
    return (x*y)%mod;
}

ll diff(ll x, ll y) {
    return (x - y <0  ? x- y + mod : x - y);
}

ll bp(ll x, ll y) {
    ll ans = 1;
    while (y) {
        if (y&1) ans = mul(ans, x);
        x = mul(x, x);
        y>>=1;
    }
    return ans;
}
const int maxn =1e6+10;
ll fact[maxn],rfact[maxn];

ll C(int n, int k) {
    return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

void solve() {
    int n, k; cin >> n >> k;
    vector<int> tak(n);
    for (int j = 0; j < k; j++) {
        int v; cin >> v; v--; tak[v] = 1;
    }
    vector<vector<int>> g(n);
    for (int i = 1; i < n;i++) {
        int p; cin >> p; p--;
        g[p].pb(i);
    }
    vector<int> sub(n, 1);
    for (int v = n - 1; v >= 0; v--) for(int u : g[v]) sub[v] += sub[u];

    for (int i = 0; i < n; i++) {
    if (tak[i]) {
        ll ans = bp(2, sub[i] - 1);
        vector<ll> dp(3);
        dp[0] = 1;
        for (int u : g[i]) {
            vector<ll> newdp(3);
            for (int cnt =0 ;cnt <= sub[u]; cnt++) {
                ll w = C(sub[u], cnt);
                for(int ws=0;ws<=3;ws++) {
                    newdp[min(2,ws+1)]=  sum(newdp[min(2, ws+1)], mul(dp[ws], w));
                }
            }
            swap(dp, newdp);
        }
        ans= sum(ans, dp[2]);
        cout << ans << '\n';
    }
    }

}

signed main() {
    int t = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        // cin >> t;
    #else 
        cin.tie(0)->sync_with_stdio(false);
    #endif 

    fact[0] = 1;
    for (int j = 1; j < maxn; j++) fact[j] = mul(fact[j - 1], j);
    rfact[maxn - 1] = bp(fact[maxn - 1], mod - 2);
    for (int j = maxn - 2; j >=0 ; j--) rfact[j] = mul(rfact[j + 1], j + 1);

    while (t--) solve();

    return 0;
}