Page not loading? Try clicking here.
Placeholder

#1495

Diagonal zigzag 1s 64MB

Problems

Given the size of a square, write a program that fills the square in a diagonal zigzag pattern as described below.

Conditions

  1. Start filling numbers from the top-left corner.

  2. Continue filling the square in a zigzag pattern along the diagonals, increasing numbers by 1 consecutively.


Input

A single integer 𝑛 (1\le n \le100) is given, representing the size of the square.


Output

Print the square after filling it with numbers in the diagonal zigzag pattern described above.

Separate numbers with a space.


Example #1

3
1 3 4 

2 5 8
6 7 9

Example #2

2
1 3

2 4


Source

JUNGOL

You must sign in to write code.