#include #include #include #include #include using namespace std; using u32 = uint32_t; constexpr u32 O = 31, N = 1U << 23, M = N * 119 + 1, // 998'244'353 M2 = M - 2; inline constexpr u32 mod_mul(uint64_t x, u32 y) { return static_cast(x * y % M); } inline constexpr u32 mod_pow(u32 a, u32 n) { u32 res = 1; for(; n; n>>=1) { if(n & 1) { res = mod_mul(res, a); } a = mod_mul(a, a); } return res; } void myfmt(vector *a, bool inv) { const u32 n = static_cast(a->size()); for(u32 H=1, W=n>>1; H>=1) { vector y = *a; u32 r = mod_pow(O, N/(H*2)); if(inv) { r = mod_pow(r, M2); } u32 w = 1; for(size_t k=0; kat(W* k +j) = y0 + y1 < M ? y0 + y1 : y0 + y1 - M; a->at(W*(k+H)+j) = y0 >= y1 ? y0 - y1 : y0 - y1 + M; } w = mod_mul(w, r); } } } void fmt(vector *a) { myfmt(a, false); } void ifmt(vector *a) { myfmt(a, true); u32 n = static_cast(a->size()); u32 inv = mod_pow(n, M2); for(size_t i=0; iat(i) = mod_mul(a->at(i), inv); } } vector convol(vector a, vector b) { size_t n = 1; while(n < a.size() + b.size()) { n <<= 1; } a.resize(n); b.resize(n); fmt(&a); fmt(&b); vector c(n); for(size_t i=0; i *a, vector *b) { size_t n = 1; while(n < a->size() + b->size()) { n <<= 1; } a->resize(n); b->resize(n); fmt(a); fmt(b); for(size_t i=0; iat(i) = mod_mul(a->at(i), b->at(i)); } ifmt(a); } int main(void) { int n, Q; scanf("%d%d", &n, &Q); queue> que; for(int i=0; i(--a % M), 1}); } while(que.size() > 1) { vector a = que.front(); que.pop(); vector b = que.front(); que.pop(); convol(&a, &b); que.emplace(a); } vector v = que.front(); for(int q=0; q