#include #define int long long #define PII pair #define fir first #define sec second using namespace std; const int B=450,mod=998244353; int q; int f[500005],inv[500005],F[500005]; int ans[500005]; struct node{ int x,y,id; } a[200005]; bool cmp(node x,node y){ if(x.x/B!=y.x/B) return x.x/B>q; for(int i=1;i<=q;i++){ cin>>a[i].x>>a[i].y; a[i].y--,a[i].x--; a[i].id=i; } sort(a+1,a+1+q,cmp); int l=1,r=1,s=1; for(int i=1;i<=q;i++){ while(l