from bisect import bisect_right a = [] for i in range(1, 10**8+1, 2): j = i*i if j > 10**15: break while j <= 10**15: a.append(j) j *= 2 a.sort() for _ in range(int(input())): l, r = map(int, input().split()) print((bisect_right(a, r)-bisect_right(a, l-1))%2)