// https://github.com/potato167/po167_library #include #include using namespace std; using ll=long long; const ll ILL=2167167167167167167; const int INF=2100000000; #define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define all(p) p.begin(),p.end() template using pq_ = priority_queue, greater>; template int LB(vector &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();} template int UB(vector &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();} template bool chmin(T &a,T b){if(b bool chmax(T &a,T b){if(a void So(vector &v) {sort(v.begin(),v.end());} template void Sore(vector &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});} bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;} template void vec_out(vector &p,int ty=0){ if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'< T vec_min(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;} template T vec_max(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;} template T vec_sum(vector &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;} int pop_count(long long a){int res=0;while(a){res+=(int)(a&1),a>>=1;}return res;} template T square(T a){return a * a;} #include using mint = atcoder::modint998244353; #include mint sum_mint(mint a, mint b) { return a + b; } mint e_mint() { return 0; } int op(int a, int b) { return (a | b); } int e() { return 0; } void solve(); // DEAR MYSTERIES / TOMOO int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; rep(i, 0, t) solve(); } void solve(){ int N, Q; cin >> N >> Q; vector A(N); rep(i, 0, N) cin >> A[i]; srand(167); vector hash(N); rep(i, 0, N) hash[i] = rand(); atcoder::segtree seg(A); const int D = 30; vector p2(N + 100); p2[0] = 1; rep(i, 1, 100 + N) p2[i] = p2[i - 1] * 2; vector> H; rep(i, 0, D) { vector init(N); rep(j, 0, N) if (A[j] & (1 << i)) init[j] = hash[j]; H.push_back(atcoder::segtree(init)); } vector order(D); rep(d, 0, D) order[d] = d; vector val(D); while (Q--) { int t; cin >> t; if (t == 1) { int i, x; cin >> i >> x; i--; seg.set(i, x); rep(d, 0, D) { if (x & (1 << d)) H[d].set(i, hash[i]); else H[d].set(i, 0); } } else { int l, r; cin >> l >> r; l--; auto tmp = seg.prod(l, r); mint ans = (ll(tmp)) * (ll(tmp)); ans *= 2; rep(d, 0, D) val[d] = H[d].prod(l, r); sort(all(order), [&](int a, int b) { return val[a].val() < val[b].val(); }); mint sum = 0; // cout << ans.val() << " "; for (int a = 0, b = 0; a < D; a = b) { mint sum2 = 0; while (b != D && val[order[a]] == val[order[b]]) { sum2 += (1 << order[b]); b++; } if (val[order[a]] == 0) continue; ans -= sum * sum2 * 2; sum += sum2; } // cout << ans.val() << "\n"; ans /= 4; ans *= p2[r - l]; cout << ans.val() << "\n"; } } } /* * 区間に対する、総 xor の 2 乗 * 単体 bit の2乗は、単純に1個以上あるなら半分の確率でok * 2つのやつは、結局基底があるかいなかになる * 01, 10, 11 のうち、1種類しかないならば、 * 11 だけなら 1/2 * それ以外は 0 * 他は 1/4 * 01, 10 だけというのは簡単に検知ができる * 11 だけがむずい * まあ各桁でhashでもなんでも持っておけばいいんだけど * データの保持多すぎ * 010 * 011 * 100 */