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

using namespace __gnu_pbds;
using namespace std;
using ordered_set  = tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>;

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

vector<vector<int> > g;
vector<int> x;
int n, k; 
int mod = 998244353;

void solve1() {

}

vector<int> s;
void dfs(int v, int p) {
  s[v] = 1;
  for (auto u : g[v]) if (u != p) {
    dfs(u,v);
    s[v] += s[u];
  }
}

int bin_pow(int x, int b) {
    if (b == 0) return 1;
    if (b % 2 == 1) return x * bin_pow(x,b-1) % mod;
    return bin_pow(x * x % mod, b / 2);
}

void solve2() {
  s.resize(n);
  dfs(0,-1);
  int d = x[0];

  int all = bin_pow(2, s[d]);
  for (auto u : g[d]) if (s[u] < s[d]) {
    all = (all - bin_pow(2, s[u]) + mod) % mod;
  }
  cout << all<<'\n';
}

void solve3( ){
  int ans = 1; 
  int cnt = 1;
  vector<int> ck(n, 0);
  for (auto el : x) ck[el] = 1;

  for (int i = 0;i < n;i++) {
    if (ck[i]) cnt++;
    else ans = ans * cnt % mod;
  }
  cout << ans;
}

void solve() {
   cin >> n >> k;   

   x.resize(k);
   g.resize(n);

   for (int i = 0 ;i < k;i++) {
    cin >> x[i];
    x[i]--;
   }

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


if (k == 1) {
  solve2();
} else {
  solve3();
}
 
   
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int t = 1;
    //  cin >> t;
    while (t --> 0) solve();
}
/*
4
3 -6
4 -10
-7 -3
-3 6
3 3 -1 -1
*/