#include <bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("no-stack-protector")

//#define D_GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pii pair<int, int>

typedef long long ll;
typedef long double ld;

#define int long long

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int mod = 998244353;
const int inf = 1e9 + 9;



void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> x(k), p(n);
    vector<int> v(n);
    for (auto &i: x) cin >> i, v[i] = 1;
    for (auto &i: p) cin >> i;
    int ans = 1, c = 0;
    for (int i = 0; i < n; i++) {
        if (v[i]) {
            c++;
            continue;
        }
        ans *= (c + 1);
        ans %= mod;
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef Local
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Local
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}