Ishaan's Curiosity
Submissions: 1062   Accuracy:

11.49%

  Difficulty: Easy   Marks: 2

Ishaan recently found out about the bitwise OR. He is really curious about its working. He wants to build a calculator which takes 2 integers A, B as input and outputs the bitwise OR of all the integers in the range [A, B] (both inclusive).
Help him build a OR calculator.

Input : 
First line of input contains a single integer T denoting the number of test cases.For each test case, there are 2 space-separated integers A and B.

Output : 
For each test case, print the required answer in a new line.

Constraints : 
1 <= T <= 100
1 <= A < B <= 10^12

Example : 
Input :
 
3
3 8
12 18
18 21
Output : 
15
31
23

Explanation : 
Case 1 :
3 | 4 | 5 | 6 | 7 | 8 = 15

Case 2 : 
12 | 13 | 14 | 15 | 16 | 17 | 18 = 31

Case 3 : 
18 | 19 | 20 | 21 = 23

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: goyalanubhav11


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.