for _ in range(int(input())): x,y = map(int,input().split()) while x>>y&1: y += 1 print((1<