#include using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' //#define vec vector //#define mat vector > #define fi first #define se second #define double long double typedef long long ll; typedef unsigned long long ull; typedef pair pll; //typedef long double ld; typedef complex Complex; const ll INF=1e9+7; const ll MOD=998244353; const ll inf=INF*INF; const ll mod=MOD; const ll MAX=200010; const double PI=acos(-1.0); typedef vector > mat; typedef vector vec; void solve(){ ll n,q;cin>>n>>q; vectorc(n+2); c[0]=1; REP(i,1,n+2)c[i]=c[i-1]*2LL; while(q--){ ll s,t;cin>>s>>t; ll a=0,b=0; if(s){ while(s%c[a]==0){ a++; } a--; } while(t%c[b]==0){ b++; } b--; vectorx(1),y(1); x[0]=s,y[0]=t; ll now=s; REP(i,a+1,n+2){ now=((now+c[i]-1LL)/c[i])*c[i]; x.pb(now); //cout<b){ ans+=(y[j]-y[j+1])/c[b]; b++; j++; } while(x[i+1]x[i])ans+=(y[j]-x[i])/c[a]-1; else ans--; cout<