Problem7481-- [CSES Problem Set] Number Spiral

7481: [CSES Problem Set] Number Spiral

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

A number spiral is an infinite grid whose upper-left square has number $1$. 
Here are the first five layers of the spiral:

Your task is to find out the number in row $y$ and column $x$.

Input

The first input line contains an integer $t$: the number of tests.
After this, there are $t$ lines, each containing integers $y$ and $x$.

Output

For each test, print the number in row $y$ and column $x$.

Constraints

$1≤t≤10^5$
$1≤y,x≤10^9$

Sample 1 Input

3
2 3
1 1
4 2

Sample 1 Output

8
1
15

HINT

相同题目:CSES 1071

Source/Category