#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- ll N,M; ll L,R; const ll mo=998244353; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; map ev; FOR(i,M) { cin>>L>>R; L--; ll hash=((rand()%(1LL<<30))<<30)+(rand()%(1<<30)); ev[L]^=hash; ev[R]^=hash; } ll preh=ev[0]; ll pre=0; ev[N]^=0; map count; ll P=0; FORR2(a,b,ev) if(a) { ll num=a-pre; if(preh) { P+=1LL*(count[preh]%mo)*(num%mo)%mo; P+=1LL*(num%mo)*((num-1)%mo)%mo*((mo+1)/2)%mo; } count[preh]+=num; pre=a; preh^=b; } ll N0=count[0]; ll ret=((N+N0)%mo*((N+N0)%mo)%mo+N%mo+mo-N0%mo+2*P)%mo; FOR(i,M-2) ret=2*ret%mo; cout<