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

an0nym0u5 | 63 |

bro_C_code | 62 |

SeungminLee | 58 |

joey_tribbiani | 47 |

ayush31g | 40 |

Ibrahim Nash | 361 |

blueberry | 315 |

xiaowang | 306 |

sushanto | 244 |

rutvikpatel29 | 238 |

akhayrutdinov | 4864 |

Quandray | 4236 |

Ibrahim Nash | 4025 |

sanjay05 | 3668 |

GB11 | 2857 |