I=input for t in range(int(I())): x,y=map(int,I().split()) d=y while d<60: if x>>d&1<1:break d+=1 print((1<