#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5 + 10;
const int N2 = 262144;
const int MOD = 998244353;
inline void print_frac(int x) {
if(x <= 200) cout << x << ' ';
else {
for(int i = 1; i <= 200; i++)
if((ll)x * i % MOD <= 200) {
cout << (ll)x * i % MOD << '/' << i << ' ';
return;
}
cout << x << ' ';
}
}
inline void add(int &a, int b) { a += b; (a >= MOD) && (a -= MOD); }
inline int mod(int a) { return (a >= MOD) ? (a - MOD) : a; }
inline int qpow(int a, int b) {
int res = 1;
while(b) {
if(b & 1) res = (ull)res * a % MOD;
a = (ull)a * a % MOD;
b >>= 1;
}
return res;
}
inline void ntt(int a[], int n, int g) {
static int swp[N2];
for(int i = 1; i < n; i++) swp[i] = (swp[i >> 1] >> 1) | (n >> 1) * (i & 1);
for(int i = 0; i < n; i++) if(i < swp[i]) swap(a[i], a[swp[i]]);
for(int k = 1; k < n; k <<= 1)
for(int i = 0, w0 = qpow(g, (MOD - 1) / (k << 1)); i < n; i += (k << 1))
for(int j = 0, w = 1; j < k; j++, w = (ull)w * w0 % MOD) {
int x = a[i + j], y = (ull)a[i + j + k] * w % MOD;
a[i + j] = mod(x + y), a[i + j + k] = mod(x - y + MOD);
}
if(g == 332748118) for(int i = 0, inv_n = qpow(n, MOD - 2); i < n; i++) a[i] = (ull)a[i] * inv_n % MOD;
}
int n, m, k, ans;
int inv[N], fac[N], ifac[N];
int w[8];
// 感觉我的模板写的挺好看的,可以用作参考
size_t mod_len;
struct poly {
vector<int> a;
inline int &operator[](size_t index) { return a[index]; }
inline const int &operator[](size_t index) const { return a[index]; }
inline poly() {}
inline poly(size_t _n) { a.resize(_n); }
inline poly(const poly &b) { a.resize(mod_len); for(size_t i = 0; i < mod_len; i++) a[i] = b[i]; }
inline poly(poly &&b) { a = move(b.a); a.resize(mod_len); }
inline void resize(size_t _n) { a.resize(_n); }
inline poly &operator=(const poly &b) { a.resize(mod_len); for(size_t i = 0; i < mod_len; i++) a[i] = b[i]; return *this; }
inline poly operator+(const poly &b) const { poly res(mod_len); for(size_t i = 0; i < mod_len; i++) res[i] = mod(a[i] + b[i]); return res; }
inline poly &operator+=(const poly &b) { for(size_t i = 0; i < mod_len; i++) add(a[i], b[i]); return *this; }
inline poly operator-(const poly &b) const { poly res(mod_len); for(size_t i = 0; i < mod_len; i++) res[i] = mod(a[i] + MOD - b[i]); return res; }
inline poly operator-() const { poly res(mod_len); for(size_t i = 0; i < mod_len; i++) res[i] = mod(MOD - a[i]); return res; }
inline poly dot(const poly &b) const { poly res(mod_len); for(size_t i = 0; i < mod_len; i++) res[i] = (ull)a[i] * b[i] % (size_t)MOD; return res; }
inline poly &dot_eq(const poly &b) { for(size_t i = 0; i < mod_len; i++) a[i] = (ull)a[i] * b[i] % (size_t)MOD; return *this; }
inline void ntt(int g) { if(mod_len > a.size()) resize(mod_len); ::ntt(a.data(), mod_len, g); }
inline poly operator*(const poly &b) const { poly x(*this), y(b); mod_len <<= 1, x.ntt(3), y.ntt(3), x.dot_eq(y), x.ntt(332748118), mod_len >>= 1, x.resize(mod_len); return x; }
};
struct mat {
poly a[4][4];
inline poly *operator[](size_t index) { return a[index]; }
inline const poly *operator[](size_t index) const { return a[index]; }
inline mat() {}
inline mat(size_t _n) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j].resize(_n); }
inline mat(const mat &b) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j] = b[i][j]; }
inline mat(mat &&b) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j] = move(b[i][j]); }
inline void resize(size_t _n) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j].resize(_n); }
inline mat &operator=(const mat &b) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j] = b[i][j]; return *this; }
inline mat operator+(const mat &b) const { mat res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) res[i][j] = a[i][j] + b[i][j]; return res; }
inline mat operator-(const mat &b) const { mat res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) res[i][j] = a[i][j] - b[i][j]; return res; }
inline mat operator-() const { mat res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) res[i][j] = -a[i][j]; return res; }
inline mat dot(const mat &b) const { mat res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) for(size_t k = 0; k < m; k++) res[i][k] += a[i][j].dot(b[j][k]); return res; }
inline void ntt(int g) { for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) a[i][j].ntt(g); }
inline mat operator*(const mat &b) const { mat x(*this), y(b); mod_len <<= 1, x.ntt(3), y.ntt(3), x = x.dot(y), x.ntt(332748118), mod_len >>= 1, x.resize(mod_len); return x; }
inline mat get_inv() const {
mat res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) res[i][j][0] = (assert(a[i][j][0] == (i == j)), a[i][j][0]);
size_t pre_modlen = mod_len;
for(mod_len = 2; mod_len <= pre_modlen; mod_len <<= 1) {
mat F = (*this); mod_len <<= 1, res.ntt(3), F.ntt(3);
res = res + res - res.dot(F).dot(res);
res.ntt(332748118), mod_len >>= 1, res.resize(mod_len);
} mod_len = pre_modlen; return res;
}
} I;
struct vec {
poly a[4];
inline poly &operator[](size_t index) { return a[index]; }
inline const poly &operator[](size_t index) const { return a[index]; }
inline vec() {}
inline vec(size_t _n) { for(size_t i = 0; i < m; i++) a[i].resize(_n); }
inline vec(const vec &b) { for(size_t i = 0; i < m; i++) a[i] = b[i]; }
inline vec(vec &&b) { for(size_t i = 0; i < m; i++) a[i] = move(b[i]); }
inline void resize(size_t _n) { for(size_t i = 0; i < m; i++) a[i].resize(_n); }
inline vec &operator=(const vec &b) { for(size_t i = 0; i < m; i++) a[i] = b[i]; return *this; }
inline vec operator+(const vec &b) const { vec res(mod_len); for(size_t i = 0; i < m; i++) res[i] = a[i] + b[i]; return res; }
inline vec operator-(const vec &b) const { vec res(mod_len); for(size_t i = 0; i < m; i++) res[i] = a[i] - b[i]; return res; }
inline vec operator-() const { vec res(mod_len); for(size_t i = 0; i < m; i++) res[i] = -a[i]; return res; }
inline vec dot(const mat &b) const { vec res(mod_len); for(size_t i = 0; i < m; i++) for(size_t j = 0; j < m; j++) res[j] += a[i].dot(b[i][j]); return res; }
inline void ntt(int g) { for(size_t i = 0; i < m; i++) a[i].ntt(g); }
inline vec operator*(const mat &b) const { vec x(*this); mat y(b); mod_len <<= 1, x.ntt(3), y.ntt(3), x = x.dot(y), x.ntt(332748118), mod_len >>= 1, x.resize(mod_len); return x; }
};
vec f, g;
mat op;
int dp[N][4];
inline int trs(int s, int c) { return k == 1 ? 0 : s >> 1 | (c << k - 2); }
int main() {
inv[1] = fac[0] = ifac[0] = 1;
for(int i = 2; i < N; i++) inv[i] = MOD - (ll)inv[MOD % i] * (MOD / i) % MOD;
for(int i = 1; i < N; i++) fac[i] = (ll)fac[i - 1] * i % MOD;
for(int i = 1; i < N; i++) ifac[i] = (ll)ifac[i - 1] * inv[i] % MOD;
cin >> n >> k; k--; mod_len = n; m = (1 << k - 1);
while(mod_len != (mod_len & -mod_len)) mod_len++;
I.resize(mod_len); for(int i = 0; i < m; i++) I[i][i][0] = 1;
for(int i = 0; i < (1 << k); i++) cin >> w[i];
dp[0][0] = 1; f.resize(mod_len);
for(int i = 0; i < max(1, k - 1); i++) {
int tmp[4] = {};
for(int s = 0; s < m; s++) add(tmp[trs(s, 0)], (ll)dp[i][s] * (i + 1 >= k ? w[s] : 1) % MOD);
for(int s = 0; s < m; s++) add(dp[i + 1][s], tmp[s]);
for(int j = 1; i + 1 + j < n; j++) {
int nw[4] = {};
for(int s = 0; s < m; s++) {
add(nw[trs(s, 0)], MOD - (ll)tmp[s] * (i + 1 + j >= k ? w[s] : 1) % MOD);
add(nw[trs(s, 1)], (ll)tmp[s] * (i + 1 + j >= k ? w[s | 1 << k - 1] : 1) % MOD);
}
for(int s = 0; s < m; s++) {
add(dp[i + 1 + j][s], (ll)nw[s] * ifac[j + 1] % MOD);
tmp[s] = nw[s];
}
}
// 只有 i=0 时可以添加前缀连续 1。
if(i == 0) {
for(int s = 0; s < m; s++) tmp[s] = 0;
for(int s = 0; s < m; s++) tmp[s] = dp[i][s];
for(int j = 1; i + j < n; j++) {
int nw[4] = {};
for(int s = 0; s < m; s++) {
add(nw[trs(s, 0)], MOD - (ll)tmp[s] * (i + j >= k ? w[s] : 1) % MOD);
add(nw[trs(s, 1)], (ll)tmp[s] * (i + j >= k ? w[s | 1 << k - 1] : 1) % MOD);
}
for(int s = 0; s < m; s++) {
add(dp[i + j][s], (ll)nw[s] * ifac[j + 1] % MOD);
tmp[s] = nw[s];
}
}
}
for(int s = 0; s < m; s++) dp[i][s] = 0;
}
for(int s = 0; s < m; s++) {
for(int i = 0; i < n; i++) f[s][i] = dp[i][s];
}
op.resize(mod_len);
for(int s = 0; s < m; s++) {
int tmp[4] = {};
tmp[trs(s, 0)] = w[s];
add(op[s][trs(s, 0)][1], w[s]);
for(int i = 1; i < n - 1; i++) {
int nw[4] = {};
for(int t = 0; t < m; t++) {
add(nw[trs(t, 0)], MOD - (ll)tmp[t] * w[t] % MOD);
add(nw[trs(t, 1)], (ll)tmp[t] * w[t | 1 << k - 1] % MOD);
}
for(int t = 0; t < m; t++) {
add(op[s][t][i + 1], (ll)nw[t] * ifac[i + 1] % MOD);
tmp[t] = nw[t];
}
}
}
g = f * (I - op).get_inv();
for(int s = 0; s < m; s++) add(ans, g[s][n - 1]);
cout << (ll)ans * fac[n] % MOD << '\n';
return 0;
}