All Squares

No attempts yetTime limit1sMemory limit128 MB

Problem

Geometrically every square has one well defined centre point. On a grid that holds only when the sides of the square span an odd number of points. Every odd number can be written as 2k+12k+1, so a square whose sides are 2k+12k+1 points long is said to have size kk.

A pattern of squares is built with these rules.

  1. The largest square has size kk, so its sides are 2k+12k+1 points long, and it sits at the centre of a grid of size 1024, whose sides are 2049 points long.
  2. The smallest permissible square has size 1 and the largest has size 512, so 1k5121 \le k \le 512.
  3. A square of size s>1s > 1 has a square of size s/2s / 2 centred on each of its 4 corners. The division is integer division, so 9/2=49 / 2 = 4. A square of size 1 puts nothing on its corners.
  4. The top left corner of the grid has coordinates (0,0)(0, 0).

A value of kk therefore fixes one pattern. The picture below shows the pattern for k=15k = 15.

Any point of the grid is surrounded by zero or more squares. A point lying on the border of a square counts as surrounded by that square.

Read a value of kk and the coordinates of a point, then report how many squares surround the point.

Input

Each line of input holds 3 integers: kk, the xx coordinate of the point, and the yy coordinate of the point, with 1k5121 \le k \le 512 and 0x,y20480 \le x, y \le 2048. The input ends with a line holding three zeroes, 0 0 0, which is not a query.

Output

Print one line for every query line of the input. Each line holds the number of squares that surround the given point.