#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;
int main(){
int num;
cin >> num;
int arr[101][101];
for (int c = 0; c < num; c++){
for (int r = 0; r < num; r++){
int smallest = 0;
bool found = false;
int arrR[101];
int arrC[101];
//cout << r << "," << c << ": " << "rArr: ";
for(int i = 0; i < num; i++){
arrR[i] = arr[r][i];
//cout<<arrR[i]<<" ";
}
//cout << "\n";
//cout << r << "," << c << ": " << "cArr: ";
for(int i = 0; i < num; i++){
arrC[i] = arr[i][c];
//cout<<arrC[i]<<" ";
}
while(!found){
smallest++;
int *rPointer = std::find(std::begin(arrR), std::end(arrR), smallest);
int *cPointer = std::find(std::begin(arrC), std::end(arrC), smallest);
if(rPointer == std::end(arrR) && cPointer == std::end(arrC)){
found = true;
}
}
//cout << "\n" << r << "," << c << ": " << "smallest: " << smallest << "\n";
arr[r][c] = smallest;
//cout << "END\n";
}
}
for(int r2 = 0; r2 < num; r2++)
{
if(r2 != 0){
cout << "\n";
}
for(int c2 = 0; c2 < num; c2++)
{
if(c2 != 0){
cout<<" " << arr[r2][c2];
}else{
cout<<arr[r2][c2];
}
}
}
return 0;
}