// #pragma GCC optimize("Ofast")

#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define all(x) x.begin(), x.end()

#ifdef DEBUG
    #define debug(x) {cout << __func__ << ":" << __LINE__ << " " << #x << " = " << x << "\n";};
    #define debugw(x) {cout << __func__ << ":" << __LINE__ << " " << x << "\n";};
#else
    #define debug(x)
    #define debugw(x)
#endif

const int mod = 998'244'353;
// const int N = 1e6;

int n, k;

int binpow(int a, int n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int res = binpow(a, n / 2);
        return ( (ll)res * res ) % mod;
    } else {
        int res = binpow(a, n - 1);
        return ((ll)res * a) % mod;
    }
}

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

    vector<int> x(k + 1);

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


    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
    }

    int res = 1;
    int last = -1;

    x[k] = n;

    sort(all(x));

    for (int i = 0; i <= k; i++) {
        int nw = binpow(i + 1, x[i] - last - 1);

        last = x[i];

        res = ((ll)res * nw) % mod;
    }
    cout << res << "\n";
}

signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // cout << set_precision(8) << fixed;

    // ll T;
    // cin >> T;
    // while (T--) solve();

    solve();
}