问题1049--Alice and Bob

1049: Alice and Bob

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 64 MB

题目描述

Alice is a beautiful and clever girl. Bob would like to play with Alice. One day, Alice got a very big rectangle and wanted to divide it into small square pieces. Now comes a problem: if all pieces of small squares are of the same size, how big could the squares be? To Alice, it's easy to solve the problem. However, she was very busy, so she asked Bob to help her. You know Alice is such a lovely girl and of course Bob won't refuse her request. But Bob is not so smart and he is especially weak in math. So he turns to you —a genius at programming. Alice will inform Bob the length and width of the big rectangle, and Bob have to tell her the longest length for the small square. All of these numbers are in their binary representations.

输入

The first line of the input is a positive integer. This is the number of the test cases followed. Each test case contains two integer L and W in their binary representation which tells you the length and width of the very big rectangle(0< L , W < 2^1000 ).There may be one or several spaces between these integers.

输出

The output of the program should consist of one line of output for each test case. The output of each test case only contains the longest length for the small squares in its binary representation. No any redundant spaces are needed.

样例输入 Copy

2
100 1000
100 110

样例输出 Copy

100
10