#include <bits/stdc++.h>

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

const int mod = 998244353;
const int maxn = 2e5 + 1;

ll bp(ll a, int b) {
    ll res = 1;
    while (b) {
        if (b % 2) {
            res = res * a % mod;
            b--;
        }
        b /= 2;
        a = a * a % mod;
    }

    return res;
}

void solve() {
    int n, q; cin >> n >> q;

    vector<int> a(n);
    for (int i{}; i < n; i++) cin >> a[i];
    vector<int> b(q);
    for (int i{}; i < q; i++) cin >> b[i];

    vector<ll> pl(4);
    for (int i{}; i < n; i++) {
        pl[0] += bp(a[i], i + 1);
        pl[1] += bp(a[n - i - 1], i + 1);
        pl[2] += bp(n - a[i] + 1, i + 1);
        pl[3] += bp(n - a[n - i - 1] + 1, i + 1);
        pl[0] %= mod;
        pl[1] %= mod;
        pl[2] %= mod;
        pl[3] %= mod;
    }

    int st = 0;
    for (auto i : b) {
        st ^= i;
        cout << pl[st] << ' ';
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int it = 1;

    //cin >> it;

    while (it--) {
        solve();
    }
}