t = int(input())
for _ in range(t):
    x, y = map(int,input().split())
    ans = ((x^y)&(-(x^y)))
    print(ans)