def query(l,r): x,y=l,r z=(1<>=1 y>>=1 z>>=1 N,Q=map(int,input().split()) for i in range(Q): a,b=map(int,input().split()) print(query(a,b))