// template.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #define int long long

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 998244353;

int modpow(int a, int b)
{
    if (b == 0)
        return 1;
    if (b & 1)
        return 1ll * a * modpow(a, b - 1) % MOD;
    return modpow(1ll * a * a % MOD, b >> 1);
}

const int MAXN = 666;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector <int> x(k);
    for (auto& i : x)
    {
        cin >> i; i--;
    }
    vector <int> p(n - 1);
    for (auto& i : p)
    {
        cin >> i; i--;
    }
    vector <bool> used(n);
    for (auto& i : x)
    {
        used[i] = true;
    }
    vector <int> pref(n + 1, 1);
    for (size_t i = 0; i < n; i++)
    {
        pref[i + 1] = pref[i] + (used[i] ? 1 : 0);
    }
    ll ans = 1;
    for (size_t i = 0; i < n; i++)
    {
        if (!used[i])
        {
            ans *= pref[i];
            ans %= MOD;
        }
    }
    cout << ans << '\n';
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
