#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 using A = array; A op(A a,A b){ return a; } A e(){ A ret; ret[0] = 0,ret[1] = (1<<30)-1; return ret; } A mapping(A a,A b){ A ret; ret[0] = 0,ret[1] = 0; rep(i,30){ rep(j,2){ ret[j] |= ((a[(b[j]>>i)&1]>>i)&1)<>i)&1]>>i)&1)<>N>>Q; vector m(N); rep(i,N)cin>>m[i]; lazy_segtree seg(N); rep(i,Q){ char c; cin>>c; int l,r,x; cin>>l>>r>>x; l--; A t; t[0] = 0,t[1] = 0; rep(j,30){ //cout<>j)&1)t[0] |= 1<>j)&1)t[0] |= 1< dp(31,0); dp[0] = 1; rep(i,N){ auto ret = seg.get(i); vector tdp(31,vector(2,0)); int M = m[i]; tdp[0][0] = 1; for(int j=29;j>=0;j--){ vector ndp(31,vector(2,0)); rep(k,31){ rep(l,2){ if(tdp[k][l]==0)continue; rep(n,2){ int kk = k,ll = l; if((ret[n]>>j)&1)kk++; if(l==0){ if((M>>j)&1){ if(n==0)ll++; } else{ if(n==1)continue; } } ndp[kk][ll] += tdp[k][l]; } } } swap(tdp,ndp); } vector ndp(31,0); rep(j,31){ rep(k,31){ ndp[max(j,k)] += dp[j] * (tdp[k][0] + tdp[k][1]); } } swap(dp,ndp); } mint ans = 0; rep(i,dp.size())ans += dp[i] * i; cout<