#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define len(v) (int)v.size()

using namespace std;
using ll = long long;
using ld = long double;

const ll Mod = 998'244'353;
vector<vector<int>> g;
vector<int> isx;
vector<vector<ll>> dp;
vector<ll> pow2;
vector<ll> cntd;
vector<int> par, h;
ll ans;
int n, k;

void dfs(int v)
{
    for (int u : g[v])
    {
        par[u] = v;
        h[u]= h[v] + 1;
        dfs(u);
    }
}

void make(int pos, vector<pair<int, int>> &arr)
{
    if (pos == n)
    {
        bool c = 1;
        for (int i = 0; i < n; ++i)
        {
            if (isx[i])
            {
                if (arr[i].first == i)
                {
                    continue;
                }
                set<int> st;
                for (int j = 0; j < n; ++j)
                {
                    if (arr[j].first == i)
                    {
                        st.insert(arr[j].second);
                    }
                }
                if (len(st) < 2)
                {
                    c = 0;
                    break;
                }
            }
        }
        ans = (ans + c) % Mod;
        return;
    }
    arr[pos] = {-1, -1};
    make(pos + 1, arr);
    int lt = -1;
    int cur = pos;
    while (cur != -1)
    {
        arr[pos] = {cur, lt};
        if (isx[cur])
        {
            make(pos + 1, arr);
        }
        lt = cur;
        cur = par[cur];
    }
}

void solve()
{
    cin >> n >> k;
    ans = 0;
    g.assign(n, {});
    isx.assign(n, 0);
    par.assign(n, 0);
    h.assign(n, 0);

    dp.assign(2, vector<ll>(n, 0));
    pow2.assign(n + 1, 1);
    for (int i = 1; i <= n; ++i)
    {
        pow2[i] = (pow2[i - 1] * 2) % Mod;
    }
    vector<int> x(k);
    for (int i = 0; i < k; ++i)
    {
        cin >> x[i];
        --x[i];
        isx[x[i]] = 1;
    }
    for (int i = 1; i < n; ++i)
    {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }
    par[0] = -1;
    dfs(0);
    vector<pair<int, int>> arr(n);
    make(0, arr);
    cout << ans;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    //cin >> t;

    while (t--)
    {
        solve();
        cout << '\n';
    }
    return 0;
}
