#include <iostream>
using namespace std;
int main()
{
int num;
cin >> num; // get the input(number of rows and colums)
int table[num][num]; // create the main table that will be outputted in the end of the program
//bool usedY[num] = false; // create an array that keeps track of what numbers have been used on the Y row
bool used[num]; // create an array that keeps track of what numbers have been used on the X row
for(int i = 0; i < num; i++) // fill table with zeroes
for(int j = 0; j < num; j++)
table[i][j] = 0;
for(int u = 0; u < num; u++)
{
used[u] = false;
}
for(int y = 0; y < num; y++) // loop that goes through the Y axis
{
for(int x = 0; x < num; x++) // loop that goes through the X axis
{
for(int i = x; i >= 0; i--) // loop that checks what numbers have been used in the left side of current position on the X axis
{
used[int((table[y][i])-1)] = true;
}
for(int i = y; i >= 0; i--) // loop that checks what numbers have been used on the Y axis
{
used[int((table[i][x])-1)] = true;
}
for(int j = 0; j < num; j++)
{
if(used[j] == 0)
{
for(int i = 0; i < num; i++)
table[y][x] = j+1;
break;
}
}
for(int u = 0; u < num; u++)
{
used[u] = false;
}
}
}
for(int i = 0; i < num; i++)
{
for(int j = 0; j < num; j++)
cout << table[i][j] << " ";
cout << endl;
}
}