Number Steps
InterviewTime limit1sMemory limit128 MB
Given a point, print the number written there by a fixed boustrophedon path over the plane, or No Number if the point is empty.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Starting from the point on the plane, the non-negative integers are written one per point following the pattern shown in the figure below. For example, , , and are written at the points , , and respectively, and the pattern continues in the same way.

Given the coordinates of a point, write a program that prints the number written at that point, or reports that no number is written there. Every input coordinate satisfies .
Input
The first line contains , the number of test cases. Each of the following lines contains two integers and , the coordinates of a point.
Output
For each point, print the number written at that point on its own line. If no number is written at that point, print No Number instead.