import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.NoSuchElementException; public class Main implements Runnable { //Runnableを実装する public static void main(String[] args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); //16MBスタックを確保して実行 } public void run() { solve(); } final long mod=998244353; class Query implements Comparable { int l; int r; int p; long x; int id; public Query(int l, int r, int p, long x, int id) { this.l=l; this.r=r; this.p=p; this.x=x; this.id=id; } int reverseOrder() { int b=0; for (int i=17;i>=0;--i) { b|=((p>>i)%2)<<(17-i); } return b; } @Override public int compareTo(Main.Query o) { return Integer.compare(reverseOrder(), o.reverseOrder()); } } class SegTree { long[] a; long[] b; int[] l_pointer; int[] r_pointer; int n=1<<18; public SegTree(int n_, long[] a_, long[] b_) { a=new long[2*n-1]; b=new long[2*n-1]; l_pointer=new int[2*n-1]; r_pointer=new int[2*n-1]; Arrays.fill(a, 1); for (int i=0;i=0;--i) { long[] ab=merge(a[2*i+1], b[2*i+1], a[2*i+2], b[2*i+2]); a[i]=ab[0]; b[i]=ab[1]; l_pointer[i]=2*i+1; r_pointer[i]=2*i+2; } } long[] merge(long al, long bl, long ar, long br) { return new long[] {ar*al%mod, (ar*bl+br)%mod}; } long[] query(int l, int r, int L, int R, int k) { if (r <= L || R <= l) return new long[] {1, 0}; if (L <= l && r <= R) return new long[] {a[k], b[k]}; long[] vl=query(l, (l+r)/2, L, R, l_pointer[k]); long[] vr=query((l+r)/2, r, L, R, r_pointer[k]); return merge(vl[0], vl[1], vr[0], vr[1]); } // 0-indexed // 下から bit 目 void swap(int bit) { bit=17-bit; for (int i=0;i<(1<=0;--i) { long[] ab=merge(a[l_pointer[i]], b[l_pointer[i]], a[r_pointer[i]], b[r_pointer[i]]); a[i]=ab[0]; b[i]=ab[1]; } } long eval(int L, int R, long x) { long[] ab=query(0, n, L, R, 0); return (ab[0]*x+ab[1])%mod; } } public void solve() { FastScanner sc=new FastScanner(); PrintWriter pw=new PrintWriter(System.out); int N=sc.nextInt(); int Q=sc.nextInt(); long[] A=new long[N]; long[] B=new long[N]; for (int i=0;i list=new ArrayList<>(); for (int i=0;i>shift)%2==1) { tree.swap(shift); mask^=1<