
#include <bits/stdc++.h>

#define int long long
#define ll long long
#define pii pair<int, int>

using namespace std;

const int mod = 998244353;


signed main() {
    int n, k; cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 0; i < k; ++i) {
        int y; cin >> y;
        a[y] = 1;
    }
    vector<int> p(n);
    for (auto &y : p)
        cin >> y;
    int ans = 1;
    int cur = 1;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == 1) {
            cur++;
        } else {
            ans *= cur;
            ans %= mod;
        }
    }
    cout << ans;

}

