#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[j][i] = 0;
for(int i = 0; i < num; i++) // fill the used table with false's
used[i] = 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 = 0; i < num; i++) // loop that checks what numbers have been used on the X axis
{
if(table[i][y] == 0){}
else
{
used[int(table[i][y]-1)] = true;
}
}
for(int i = 0; i < num; i++) // loop that checks what numbers have been used on the Y axis
{
if(table[x][i] == 0)
break;
else
{
used[int(table[x][i]-1)] = true;
}
}
for(int j = 0; j < num; j++)
{
if(!used[j])
table[x][y] = j+1;
}
for(int i = 0; i < num; i++)
used[i] = false;
}
}
for(int i = num-1; i >= 0; i--)
{
for(int j = 0; j < num; j++)
cout << table[j][i] << " ";
cout << endl;
}
}