Problem H
Point Coloring
You are coloring points on an infinite grid. All points are initially colored with color $-1$. You color the point $(0, 0)$ with color $0$, and then, for each $i \geq 0$ in order, do the following:
-
Let $S$ be the set of points currently colored with color $i$.
-
For each point $(x, y)$ in $S$, color the points $(x + 2^ i, y)$ and $(x, y + 2^ i)$ with color $i+1$
You are given integers $x$ and $y$. At the end of this infinite process, what color will the point $(x, y)$ be?
Input
The first line of the input contains a single integer $t$ ($1 \le t \le 10^5$) —the number of test cases. The description of the test cases follows.
Each test case consists of a single line with two integers $x$ and $y$ ($0 \le x, y \le 10^{18}$) —the coordinates of the point to query.
Output
For each test case, output a single integer —the color of the point $(x, y)$ after this infinite process.
Sample Input 1 | Sample Output 1 |
---|---|
8 0 0 0 1 1 1 3 4 10 8 17 14 0 524287 999926342823684562 152995161783162413 |
0 1 -1 3 -1 5 19 60 |