#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int maxn=200005,mod=998244353,C=256; int add(int x, int y){x+=y; if(x>=mod) x-=mod; return x;} int sub(int x, int y){x-=y; if(x<0) x+=mod; return x;} int mul(int x, int y){return ((ll)x)*y%mod;} int fac[maxn],ifac[maxn],pw2[maxn]; int c(int n, int m){return mul(fac[n],mul(ifac[m],ifac[n-m]));} struct MoSolver { struct query { int l, r, id; bool operator < (const query &o) { if (l / C == o.l / C) return (l / C) & 1 ? r > o.r : r < o.r; return l / C < o.l / C; } }; int cur_ans,pl,pr; vector ans; vector Q; void add_query(int l, int r, int id) { // [l, r) Q.push_back({l, r, id}); ans.push_back(0); } void run() { sort(Q.begin(), Q.end()); pl = 0, pr = 0; cur_ans = 1; for (query &i : Q) { while (pl > i.l) cur_ans=sub(cur_ans,c(pr,pl)),--pl; while (pr < i.r) cur_ans=sub(mul(cur_ans,2),c(pr,pl)),pr++; while (pl < i.l) cur_ans=add(cur_ans,c(pr,pl+1)),pl++; while (pr > i.r) cur_ans=mul(add(cur_ans,c(--pr,pl)),(mod+1)/2); ans[i.id] = cur_ans; } } }de; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); fac[0]=ifac[0]=ifac[1]=1; for(int i=1; i> q; vector vec; for(int i=0; i> n >> m; vec.pb(n); de.add_query(m-1,n-1,i); } de.run(); for(int i=0; i