#include #define int long long #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define fi first #define se second #define eb emplace_back #define popc __builtin_popcount using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; typedef vector vp; typedef unsigned long long ull; typedef long double ld; int read() { int x=0,w=1; char c=getchar(); while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();} while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} return x*w; } const int N=(1<<18)+9,mod=998244353,inv2=(mod+1)/2; int n,a[N],w[N],q,t[N]; char s[N]; int ksm(int x,int y,int r=1) { for(;y;y>>=1,x=x*x%mod) if(y&1) r=r*x%mod; return r; } namespace Trie { int tot=1,ls[N<<1],rs[N<<1],h[N<<1]; vi s[N<<1]; void build(int p,int l,int r) { if(l==r) { h[p]=0; s[p].resize(1); s[p][0]=q*a[l]%mod; return; } int mid=l+r>>1; build(ls[p]=++tot,l,mid); build(rs[p]=++tot,mid+1,r); h[p]=h[ls[p]]+1; s[p].resize(1<>1; if(x<=mid) mdf(ls[p],l,mid,x,y); else mdf(rs[p],mid+1,r,x,y); rep(j,0,(1<>1; if(y<=mid) { if(!(b&(1<mid) { if(!(b&(1<