Walk Like an Egyptian

No attempts yetTime limit1sMemory limit128 MB

Problem

Walk Like an Egyptian is an old multiplayer board game once played by children of the Sahara nomad tribes. Children would collect stones and number each one. A game with $N$ players needs $N^2$ stones, and each player picks $N$ of them. The stones are laid out on an $N \times N$ grid in a peculiar order, as shown in Figure (a) (for $N = 4$). The player whose stone lands in the top-right corner loses the round. A new round is then played with $N - 1$ players, and $N - 1$ rounds in total decide the winner.

The layout follows an old rule that the Pharaohs' workers used to cross a dark room inside a pyramid without losing anyone (see Figure (b)):

  1. The first worker stands in the lower-left corner of the room.
  2. The next three workers stand around the first one, forming a quarter circle in the anti-clockwise direction.
  3. The next five workers stand around those three, this time forming a quarter circle in the clockwise direction.
  4. They keep repeating the previous two steps until the room is full. Whenever they reach the left wall or the bottom wall, they begin a larger quarter circle and alternate the direction between clockwise and anti-clockwise.

The stones are numbered $1, 2, 3, \ldots, N^2$ in the exact order in which the workers take their places. Given $N$, determine the number written on the stone that ends up in the top-right corner of the grid.

Input

The input contains one or more test cases. Each test case is given on its own line as a single integer $N$ ($0 < N < 1000$), the number of players.

The input ends with a line containing a single zero, which is not part of the test data.

Output

For each test case, print one line in the form N => result, where $N$ is the number of players for that test case and result is the number on the stone at the top-right corner of the grid.