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<=10^{18}

**Example:**

**Input:**

2

10 11

8 16

**Output:**

5

8

Author: arun03

Deepanshusaxena | 231 |

Abhay Raghav | 221 |

Mithun Kumar | 211 |

Dext28 | 204 |

CAGEROT | 182 |

Mithun Kumar | 615 |

Deepanshu8391 | 453 |

skirmish | 420 |

???151 | 401 |

Aman Patel | 397 |

akhayrutdinov | 4748 |

Quandray | 3926 |

sanjay05 | 3668 |

Ibrahim Nash | 3664 |

surbhi_7 | 2816 |