for _ in range(int(input())): a, b = map(int, input().split()) ans = [] for i in range(60): x = b - a if x - (1 << i) > (1 << i) and a & ((1 << (i + 1)) - 1): ans.append(1<