GRIDPNT - Grid points

There's a Cartesian lattice with 0<=x,y<=n. Given one point (x1, y1>0) in this lattice rotating clockwise as little as possible around the origin find the next point (x2, y2). The given and searched points mustn't have another point between the origin (0, 0) and this point itself.
x1, y1, x2, y2 are non-negative integers.

GraphGridPnt

Score is source length.

Input

In the first line the number T (T<100) of test cases.
Then T lines with the space-separated n (1<=n<=50), x1 and y1.

Output

For each test case the space-separated x2 and y2.

Example

Input:
3
1 1 1
5 3 2
50 48 49 Output: 1 0
5 3
49 50

Added by:HWK
Date:2011-05-24
Time limit:9.989s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2012-08-07 19:43:55 numerix
The example breaks the constraints.

Last edit: 2011-05-25 18:13:59
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.