BETA

Difficulty Level: Medium

Submissions: 640 Accuracy:

14.69%

Longest common substring value of two numbers
       

Given two integers N and M. The task is to find the longest contiguous subset in binary representation of both the numbers and print its decimal value.

Note: If there are two or more longest common substrings with the same length, the print the maximum value of all the common substrings.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.
Each test case contains two integer N and M as input.

Output:
For each test case, print the decimal value of longest common substring In new line.

Constraints:
1<=T<=1000
1<=N,M<=1018

Example:
Input:
2
10 11
8 16

Output:
5
8

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

Contributor: Arun Tyagi

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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