区间[l, r]之间所有整数的异或和
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>PII;
const int N=1e5+10;
const int MOD = 80112002;
const int INF=0X3F3F3F3F;
const int dx[]={-1,1,0,0,-1,-1,+1,+1};
const int dy[]={0,0,-1,1,-1,+1,-1,+1};
const int M = 1e6 + 10;
ll f(ll x)
{
ll a = 1, b = 0;
if(x % 4 == 0) return x;
else if(x % 4 == 1) return a;
else if(x % 4 == 2) return x + 1;
return b;
}
int main()
{
int t;
cin >> t;
while(t --){
ll l, r;
cin >> l >> r;
ll a = f(l - 1);
ll b = f(r);
cout << (a ^ b) << endl;
}
}