Largest Common Vertex on a Rooted Tree

For two nodes in a complete binary tree numbered heap-style, find the deepest common ancestor k and print 10k.

Easy3TreeMathBit manipulationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

A rooted tree has 1023 vertices. Vertex 1 is the root, and the two children of vertex vv are vertex 2v2v and vertex 2v+12v+1. Under this rule each natural number from 1 to 1023 is attached to exactly one vertex. Vertices numbered 512 to 1023 have no children. The top four levels look like this.

                1
        2               3
    4       5       6       7
  8   9   10  11  12  13  14  15

Let M(a,b)M(a, b) be the largest vertex number that lies on both the path from vertex 1 to vertex aa and the path from vertex 1 to vertex bb. For example, M(4,11)=2M(4, 11) = 2 and M(7,12)=3M(7, 12) = 3.

Given two natural numbers AA and BB, let M(A,B)=kM(A, B) = k. Write a program that computes 10k10k.

Input

The first line contains the number of test cases TT (1T500001 \le T \le 50000). Each of the next TT lines holds one test case: two integers AA and BB (1A,B10231 \le A, B \le 1023, ABA \ne B) separated by a single space.

Output

For each test case, print the value of 10k10k on its own line.