PUCMM215 - E 23 Stairs pattern

no tags 

In this problem you will work on a plane, where the natural numbers are arranged in a stair pattern.

Starting on coordinate (2, 1) through (2, 23) are the first 23 natural numbers in sequence, 1 is in (2,1), 2 is in (2,2) and so on..., the next 23 natural numbers (24 to 46) are arranged from (2, 24) through (24, 24), the next 23 from (25, 24) through (25, 46), a stair pattern where each step is 24 numbers high, this pattern continues infinitely.

    Y-axis
      |                       48
      |  24 25 26 27 . . . 46 47
      |  23
      |   .
      |   .
      |   .
      |   3
      |   2
      |   1
      |_____________________________ X-axis

Input

You will be given a series of queries that could be one or two integers per line.

The last test case is 0 0.

each integer N, Xi, Yi satisfy: 1 ≤ N, Xi, Yi, ≤ 1015.

Output

If the test case is one integer you have to output two comma separated integers denoting the coordinates (x, y) of the selected number, if there are two numbers you have to output one integer that corresponds to the integer that is located in those coordinates, if there is no number with such coordinates, output the string "No Number"

Example

Input:
2
2 7
3 7
0 0

Output:
2, 2
7
No Number

hide comments
jaans: 2012-06-22 03:19:49

phew!!i had just given up but at last try it worked:) finally AC!

numerix: 2012-06-22 03:19:49

Please open it for all languages.

Ahmed Kamel [ahm.kam_92]: 2013-02-17 15:09:55

I got AC without scanning or printing long long numbers, please check your test cases.


Added by:Olson Ortiz
Date:2012-05-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP JAVA
Resource:Used in 2nd dominican ACM-ICPC Warm Up 2012 Competition in PUCMM