NSTEPS - Number Steps

Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2, ... as shown in the figure. For example, 1, 2, and 3 has been written at points (1,1), (2,0), and (3, 1) respectively and this pattern has continued.

 

Illustration

 

You are to write a program that reads the coordinates of a point (x, y), and writes the number (if any) that has been written at that point. (x, y) coordinates in the input are in the range 0...10000.

Input

The first line of the input is N, the number of test cases for this problem. In each of the N following lines, there is x, and y representing the coordinates (x, y) of a point.

Output

For each point in the input, write the number written at that point or write No Number if there is none.

Example

Input:
3
4 2
6 6
3 4

Output:
6
12
No Number

Added by:Camilo Andrés Varela León
Date:2006-11-25
Time limit:1.159s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Asia - Tehran 2000

hide comments
2019-12-08 13:38:16
Hint: Use line equations
2019-11-02 16:35:24
For one who is trying, look the figure CAREFULLY, use a ruler or a pencil if you have one. Cost me 5 WA to realised the special.

Last edit: 2019-11-02 16:36:53
2019-10-02 05:09:58
don't forget \n(new line)
2019-09-28 07:36:38
AC in one GO! Just need to see little pattern in x and y then you are good to go ;)
2019-06-27 10:05:46
Observe the path the numbers follow on the graph and difference between the numbers. The problem is easy.
2019-05-21 13:13:16
basic if else...level 0 problem..
2019-05-21 07:51:46
its easy problems, I got WA for my silly mistake.. you have to write 3 or 4 lines if, else if, then its AC, go...
2019-05-14 13:45:28
for y=x-2 case...i was deriving the pattern as (x-1)th even number is x is even and (x-1)th odd number if x is odd...which led to WA. How is this logic not working in the pattern later on..can anyone explain?
2019-04-21 01:31:04
snake_123 make sure that x is always bigger or the same as y and the difference is always 2
2019-04-20 08:02:01
sum of even coordinates is equal to the number and sum of odd coordinate -1 is equal to the number along with x>=y.. but it is not working


Last edit: 2019-04-20 08:30:11
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.