#include using namespace std; int main() { int T; cin >> T; while (T--) { long long L, R; cin >> L >> R; long long a = 0; while (R > 0) { long long l = sqrt(L) + 1e-9; long long r = sqrt(R) + 1e-9; if (l*l != L) l++; a += (r+1)/2 - l/2; L = L%2 ? L/2+1 : L/2; R /= 2; } cout << a % 2 << endl; } }