#P1035. 骑士移动网格 (Knight Moves Grid)

骑士移动网格 (Knight Moves Grid)

Source: CSES Problem Set (Task 3217)
Link: https://cses.fi/problemset/task/3217
Category: Introductory Problems

  • Time limit: 1.00 s
  • Memory limit: 512 MB

There is a knight on an n×nn \times n chessboard. For each square, print the minimum number of moves the knight needs to do to reach the top-left corner.

Input

The only line has an integer nn.

Output

Print the number of moves for each square.

Constraints

  • 4≤n≤10004 \le n \le 1000

Example

Input:

8

Output:

0 3 2 3 2 3 4 5 
3 4 1 2 3 4 3 4 
2 1 4 3 2 3 4 5 
3 2 3 2 3 4 3 4 
2 3 2 3 4 3 4 5 
3 4 3 4 3 4 5 4 
4 3 4 3 4 5 4 5 
5 4 5 4 5 4 5 6