#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 998244353;
struct mint {
    int v = 0;
    mint(int nv = 0) {
        v = nv;
        if (v < 0 || v >= mod) {
            v = (v % mod + mod) % mod;
        }
    }
};
mint operator+(mint v1, mint v2) {
    return {v1.v + v2.v >= mod ? v1.v + v2.v - mod : v1.v + v2.v};
}
mint operator-(mint v1, mint v2) {
    return {v1.v - v2.v < 0 ? v1.v - v2.v + mod : v1.v - v2.v};
}
mint operator *(mint v1, mint v2) {
    return 1LL * v1.v * v2.v % mod;
}
void operator +=(mint &v1, mint v2) {
    v1 = v2 + v1;
}
void operator *=(mint v1, mint v2) {
    v1 = v1 * v2;
}
bool operator != (mint v1, mint v2) {
    return v1.v != v2.v;
}
ostream &operator <<(ostream &out, mint v) {
    out << v.v;
    return out;
}
mint exp(mint a, int b) {
    if (b == 0) {
        return 1;
    }
    if (b & 1) {
        return exp(a, b - 1) * a;
    }
    return exp(a * a, b / 2);
}
mint f[1000], rf[1000];
class tree {
    int n, k;
    vector <vector <int>> gr;
    vector <int> is, counter;;
    mint c(int n, int k) {
        return f[n] * rf[k] * rf[n - k];
    }
    mint ans = 1;
    void dfs(int num, int d) {
        if (is[num]) {
            ++d;
        } else {
            ans *= (d + 1);
        }
        for (int next : gr[num]) {
            dfs(next, d);
        }
    }
public:
    void init() {
        cin >> n;
        cin >> k;
        gr.resize(n);
        is.resize(n);
        counter.resize(n);
        for (int i = 0; i < k; ++i) {
            int a;
            cin >> a;
            --a;
            is[a] = 1;
        }
        for (int i = 1; i < n; ++i) {
            int p;
            cin >> p;
            --p;
            gr[p].push_back(i);
        }
    }
    void get_ans() {
        dfs(0, 0);
        cout << ans << '\n';
    }
};
void bad() {
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    f[0] = 1;
    rf[0] = 1;
    for (int i = 1; i < 1000; ++i) {
        f[i] = f[i - 1] * i;
        rf[i] = exp(f[i], mod - 2);
    }
    bad();
}
