Walmart Labs OA

There is an infinite array A defined as :

A[0]=0;
A[i]=A[i-1] xor i

There are a number of queries having L, R

For each query, find the XOR of the elements between L and R(inclusive)

Constraints: 1 <= L,R <=10^15
1 <= Q <= 10^5