#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
void main() {
int seed;
cin >> seed;
vector <int> table;
table.reserve(seed * seed);
for (int row = 0; row < seed; row++) { // for each row
vector<int> buff = {};
for (int b = 1; b <= seed; b++) { // for each number
buff = {};
for (int c = 0; c < row; c++) { // for each previous row
buff.push_back(table[c * (seed) + b-1]); // add numbers up to buffer
}
for (int d = 0; d < b-1; d++) { // for
buff.push_back(table[(row)*seed+d]);
}
bool found = false;
int i = 1;
while (!found) {// check if buffer contains proposed character
if (!(find(buff.begin(), buff.end(), i) != buff.end())) {
std::cout << i << " ";
table.push_back(i);
if (b == seed) {
std::cout << std::endl;
}
else {
buff.push_back(i); // add numbers on the left to buffer
}
//table.push_back(i);
found = true;
}
i++;
}
}
}
}