Given two numbers A and B. Find the value of pair (P,Q) such that A ≤ P < Q ≤ B value of P AND Q is maximum where AND is a binary operator. Refer to this link for more information about AND operator : http://en.wikipedia.org/wiki/Bitwise_operation#AND 

Input:
First line of input contains number of test cases T. Each test case contains two numbers A and B.  

Output: 
For each test case print the value of maximum AND.  

*Constraints: * 
1 ≤ T ≤ 1000
1 ≤ A < B ≤10^18

SAMPLE INPUT
2
2 3
4 8
SAMPLE OUTPUT
2
6
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

T=int(raw_input())
for i in range(0,T):
	A,B=map(int,raw_input().split())
	if((B-1)%2==0 and (B-1)>=A):
		print (B-1)
	elif((B-1)%2==1 and (B-1)<=A):
		print A&B
	else:
		print (B-2)
'''
	maxs=0
	point=A&B
	for j in range(A,B):
		count=0
		if(j%2!=0):
			continue
		N=j
		if(maxs<=(N&B)):
			maxs=N&B
			point=j
	print point
'''