import sys,os,io input = sys.stdin.readline #input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline T = int(input()) for t in range(T): # from itertools import groupby, accumulate, product, permutations, combinations # for com in combinations(range(1,100),2): # A,B = com # print(A,B) A, B = map(int, input().split()) n = B.bit_length() m = A.bit_length() ans = [] for i in range(n-1): if A&(1<B: break A += 1<