#include <bits/stdc++.h>
#define int long long

#pragma GCC optimize("Ofast","O3","unroll-loops")
#pragma GCC target("avx2")

using namespace std;
const int MOD = 998'244'353;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 1;

int binpow(int x, int m) {
    if (m == 0)
        return 1;
    if (m == 1)
        return x;
    if (m % 2 == 0) {
        int res = binpow(x, m / 2);
        return (res * res) % MOD;
    }
    return (binpow(x, m - 1) * x) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> x(k), p(n - 1);
    for (auto &i : x)
        cin >> i;
    for (auto &i : p)
        cin >> i;

    int ans = 1;
    sort(x.begin(), x.end());
    x.push_back(n + 1);
    for (int i = 0; i < k; ++i) {
        int cnt = i + 2;
        ans *= binpow(cnt, x[i + 1] - x[i] - 1);
        ans %= MOD;
    }
    cout << ans;
}

/*
int n, k;
cin >> n >> k;
vector<int> x(n), p(k);
for (auto &i : x)
    cin >> i;
for (auto &i : p)
    cin >> i;

*/
