C. Honeycomb Distance
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

A plane is tiled completely with regular hexagons. Each hexagon is called a cell. You can move in one step from a cell to one of its adjacent cells that share an edge. You want to know the minimum number of steps to move from the central cell to the specified cell.

Each cell is specified by a pair of integers. The central cell is $$$(0, 0)$$$. One of the directions perpendicular to the edges of the regular hexagons is defined to be the rightward direction. For each cell $$$(x, y)$$$, its right adjacent cell is $$$(x + 1, y)$$$ and its upper-right adjacent cell is $$$(x, y + 1)$$$. See the figure below.

Write a program that computes the minimum number of steps required to move from the cell $$$(0, 0)$$$ to the cell $$$(x, y)$$$ for given integers $$$x$$$ and $$$y$$$.

Figure C-1: How to specify the cells
Input

The first line of the input contains only one positive integer $$$n$$$, which is the number of datasets. $$$n$$$ does not exceed $$$100$$$. Each of the following $$$n$$$ lines contains one dataset.

Each dataset consists of two integers $$$x$$$ and $$$y$$$, which satisfy $$$−1000 \le x \le 1000$$$ and $$$−1000 \le y \le 1000$$$. The destination cell is $$$(x, y)$$$.

Output

For each dataset, output one line containing the minimum number of steps required to move from the cell $$$(0, 0)$$$ to the destination cell.

Example
Input
7
0 0
0 1
1 0
2 1
2 -1
-3 2
-1 -3
Output
0
1
1
3
2
3
4