Consider you have an infinite long binary tree having a pattern as below
4 5 6 7
. . . . . . . .
You are given two nodes with values x and y, the task is to find the length of the shortest path between the two nodes.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two space separated integers x and y.
For each test case in a new line print the shortest length of the path from x to y.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.