Maximum AND

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 <=1018

Sample Input(Plaintext Link)
 2
2 3
4 8


Sample Output(Plaintext Link)
 2
6

Hackerearth Coding Challenge

#python sollution
T = int(raw_input())

for i in range(T):
	x, y = map(int,raw_input().split(" "))
	if y % 2 == 0:
		if x < ( y - 1 ) :
			y = y - 1
			x = y - 1
	elif y % 2 != 0 and x < y:
		x = y - 1
	print x & y