from math import sqrt def is_odd_divisor_sum(num: int) -> bool: str_bin_num = bin(num) num_divide_by_2 = int(str_bin_num[:str_bin_num.rfind("1")+1], 0) return sqrt(num_divide_by_2) - sqrt(num_divide_by_2) ** 2 < 1e-3 def main(): T = int(input()) for _ in range(T): L, R = map(int, input().split()) print(sum(map(is_odd_divisor_sum, range(L, R+1))) % 2) if __name__ == "__main__": main()