#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using ll = long long;
using ld = long double;
mt19937 rnd(1245);

#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll mod = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const int maxn = 1e5 + 1;
const int logn = 21;
const int sq = 350;
const ld eps = 1e-8;
const ld pi = acos(-1);

ll mmod(ll x, ll mod = mod) {
    x %= mod;
    if (x < 0) x += mod;
    return x;
}

ll gcd(ll a, ll b) {
    ll res;
    while (b != 0) {
        res = a;
        a = b;
        b = res % a;
    }
    return a;
}

ll binpow(ll a, ll n, ll mod = mod) {
    ll res = 1;
    while (n != 0) {
        if (n & 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<vector<int> > g(maxn);
ll sz[maxn], dp[maxn];

void dfs(int v, int p) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            dfs(u, v);
            sz[v] += sz[u];
        }
    }
    dp[v] += mmod(binpow(2, sz[v]) - 1);
    for (int u : g[v]) {
        dp[v] = mmod(dp[v] - binpow(2, sz[u]) + 1);
    }
}


void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> x(k);
    for (int i = 0; i < k; ++i) {
        cin >> x[i];
    }

    for (int i = 2; i < n + 1; ++i) {
        int p;
        cin >> p;
        g[p].push_back(i);
    }
    dfs(1, 0);

    for (int i = 0; i < k; i++) {
        cout << dp[x[i]] << '\n';
    }

}

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }

}