#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll mod = 998244353;

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

    ll n, k;
    cin >> n >> k;

    vector<bool> task(n);
    for (ll i = 0; i < k; ++i) {
        ll x;
        cin >> x;
        x--;

        task[x] = true;
    }

    vector<ll> p(n, -1);
    for (ll i = 1; i < n; ++i) {
        cin >> p[i];
    }

    ll ans = 1;
    ll just = 0;
    for (ll i = 0; i < n; ++i) {
        if (task[i]) {
            just++;
        }
        else {
            ans = (ans * (just + 1)) % mod;
        }
    }

    cout << ans;
}