Time Limit: 3000 MS Memory Limit: 65536 K
GLC has developed an algorithm to map each lattice point in the 2-d catesian coordinates to a nature number. For example:
(0, 0) -> 0
(1, 0) -> 1
(1, 1) -> 2
(0, 1) -> 3
(-1, 1)-> 4
and so on. If we connect every two adjacent points by a segment, we get a spiral line which starts at (0, 0).
Now, given a point on the plane, you are to find the nature number it mapped to.
The first line of input is the number of test case.
For each test case, thers is only one line contains two number x , y ( |x|, |y| <= 10,000 ).
for each test case, output the answer in one line.
Sichuan University Programming Contest 2012 Final