cho.sh
Notes
Loading...

Magic Square

Time limit

2s

Memory limit

128 MB

Problem

A magic square is an arrangement of the integers from 1 through N^2 in an N by N grid, using each integer exactly once, such that every row, every column, and the two main diagonals all have the same sum.

Given N, print any N by N magic square.

Input

The first line contains a natural number N. (3 <= N <= 300)

Output

Print any N by N magic square that satisfies the condition. Print N integers on each line, separated by spaces.