#include #include using namespace std; int phi[2<<17]; long S[2<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); for(int p=2;p<2<<17;p++)phi[p]=p; for(int p=2;p<2<<17;p++)if(phi[p]==p) { for(int j=p;j<2<<17;j+=p)phi[j]=phi[j]/p*(p-1); } for(int p=2;p<2<<17;p++)S[p]=S[p-1]+phi[p]; int T;cin>>T; long prv=0; for(;T--;) { int L,R; { long a,b; cin>>a>>b; L=a^prv; R=b^prv; } L--; long ans=0; int a=2; while(a<=R) { int qR=R/a; int qL=L/a; int ra=R/qR; if(qL>0)ra=min(ra,L/qL); if(qL