#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    const int N = 13, N2 = N*N+1, NS = N*N/2+1, N_ = N - 1;
    int M[N][N];
    int x = 0, y = 0, s = 0;
    for(int i = 1; i <= NS; ++i)
    {
        M[y][x] = i;
        M[N_-y][N_-x] = N2-i;
        if (s) { ++x; y -=  (s = y != 0); }
        else   { ++y; x -= !(s = x == 0); }
    }

    for(int r = 0; r < N; ++r)
    {
        for(int c = 0; c < N; ++c)
        {
            cout << setw(4) << M[r][c];
        }
        cout << endl;
    }
}
