#include <iostream>

using namespace std;

int main()
{
    int i = 0;
    int j = 0;
    int k = 1; //运动方向,k=1 表示运动方向从左往右移动,k=2 表示从右上角往左上角移动;
               //k=3表示向下移动;k=4表示从左上角往右上角移动
    int data[1000][1000] = { {0} };
    data[0][0] = 1;
    int n;
    cin >> n;
    while (i != n - 1 || j != n - 1) //不在最后一行或不在最后一列
    {
        if (k == 1)
        {
            data[i][j + 1] = data[i][j] + 1;
            j = j + 1;
            if (i == n - 1)
            {
                k = 4;
            }
            else
            {
                k = 2;
            }
        }
        else if (k == 2)
        {
            data[i + 1][j - 1] = data[i][j] + 1;
            i = i + 1;
            j = j - 1;
            if (j == 0 && i != n - 1)
            {
                k = 3;
            }
            else if (i == n - 1)
            {
                k = 1;
            }
            else
            {
                k = 2;
            }
        }
        else if (k == 3)
        {
            data[i + 1][j] = data[i][j] + 1;
            i = i + 1;
            if (j == n - 1)
            {
                k = 2;
            }
            else
            {
                k = 4;
            }
        }
        else if (k == 4)
        {
            data[i - 1][j + 1] = data[i][j] + 1;
            i = i - 1;
            j = j + 1;
            if (i == 0 && j != n - 1)
            {
                k = 1;
            }
            else if (j == n - 1)
            {
                k = 3;
            }
            else
            {
                k = 4;
            }
        }
    }
    for (int a = 0; a < n; a++)
    {
        for (int b = 0; b < n; b++)
        {
            cout << data[a][b] << " ";
        }
        cout << endl;
    }
}