#include using namespace std; #include using namespace atcoder; using mint=modint998244353; typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef __uint128_t u128; #define ctz32(a) ((a) ? __builtin_ctz((a)) : (32)) static const u32 fn[16] = { 0x0001u, 0x0102u, 0x0183u, 0x8041u, 0x015cu, 0x5f24u, 0xde2cu, 0x957eu, 0x01f4u, 0xf7d8u, 0x76b0u, 0x5d52u, 0xa977u, 0x20d1u, 0xc1a4u, 0x271fu}; static inline u32 to_nimber(u32 x) { u32 y = 0; for (; x; x &= x - 1) y ^= fn[ctz32(x)]; return y; } static inline u32 to_double(u32 x) { return x << 1 ^ (x < 32768 ? 0 : 93099U); } u16 ln[65536]; u16 expo[196605]; u16 *Hexpo = expo + 62133; u16 *H2expo = expo + 58731; __attribute__((constructor)) void _construct_nimber_product_() { *expo = 1; for (int i = 1; i < 65535; ++i) expo[i] = to_double(expo[i - 1]); for (int i = 1; i < 65535; ++i) { expo[i] = to_nimber(expo[i]); ln[expo[i]] = i; } memcpy(expo + 65535, expo, 131070); memcpy(expo + 131070, expo, 131070); } u16 product_16(u16 A, u16 B) { return A && B ? expo[ln[A] + ln[B]] : 0; } u16 H_16(u16 A) { return A ? Hexpo[ln[A]] : 0; } u16 H2_16(u16 A) { return A ? H2expo[ln[A]] : 0; } u16 Hproduct_16(u16 A, u16 B) { return A && B ? Hexpo[ln[A] + ln[B]] : 0; } u32 product_32(u32 A, u32 B) { u16 a = A & 65535; u16 b = B & 65535; u16 c = A >> 16; u16 d = B >> 16; u16 e = product_16(a, b); if(c==0 && d==0) { return e; } return (u32)(product_16((u16)(a ^ c), (u16)(b ^ d)) ^ e) << 16 | (Hproduct_16(c, d) ^ e); } u32 H_32(u32 A) { u16 a = A & 65535; u16 b = A >> 16; return H_16((u16)(a ^ b)) << 16 | H2_16(b); } u64 product(u64 A, u64 B) { u32 a = A & UINT_MAX; u32 b = B & UINT_MAX; u32 c = A >> 32; u32 d = B >> 32; u32 e = product_32(a, b); if(c==0 && d==0) { return e; } return (u64)(product_32(a ^ c, b ^ d) ^ e) << 32 | (H_32(product_32(c, d)) ^ e); } vector nim_prod_table(256, vector(256)); vector nim_inv_table(256); void nim_prod_precalc() { nim_prod_table[0][0]=0; nim_prod_table[0][1]=0; nim_prod_table[1][0]=0; nim_prod_table[1][1]=1; for(int d=0;d<3;++d){ int p=1<>p; unsigned long long a_l=a-(a_h<>p; unsigned long long b_l=b-(b_h<>p; unsigned long long a_l=a-(a_h<>p; unsigned long long b_l=b-(b_h<>p; unsigned long long a_l=a-(a_h<> & m, vector & is_member) { int rank=0; for(int i=0;i0){ pivot=j; break; } } if(pivot==-1){ continue; } swap(m[pivot], m[rank]); auto inv=nim_inv(m[rank][i]); m[rank][i]=1; for(int k=0;k> n >> t; vector h(t, vector(n)); for(int i=0;i> h[i][j]; --h[i][j]; } } mint ans=0; vector is_member(n, true); int rank=gauss(t, n, h, is_member); vector ranks(1<=0;--r){ for(int i=0;i0){ ranks[s]=r; break; } } } while(next_permutation(is_member.begin(), is_member.end())); } for(int r=0;r0){ if(count%2>0){ ans+=p.pow(count-ranks[s]); } else { ans-=p.pow(count-ranks[s]); } } else { if(count%2>0){ ans-=p.pow(count-ranks[s]); } else { ans+=p.pow(count-ranks[s]); } } } cout << ans.val() << endl; return 0; }