/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package datatähti;
import java.util.Scanner;
/**
*
* @author Matias
*/
public class Datatähti {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner lukija = new Scanner(System.in);
int n = Integer.valueOf(lukija.nextLine());
int[][] ruudukko = new int[n][n];
int lisattavaNumero = 1;
for (int rivi = 0; rivi < n; rivi++) {
for (int sarake = 0; sarake < n; sarake++) {
if (rivi == 0 && sarake == 0) {
ruudukko[rivi][0] = 1;
continue;
}
while (true) {
boolean reset = false;
for (int s = 0; s < sarake; s++) {
if (lisattavaNumero == ruudukko[rivi][s]) {
reset = true;
}
}
if (rivi > 0) {
for (int r = 0; r < rivi; r++) {
if (lisattavaNumero == ruudukko[r][sarake]) {
reset = true;
}
}
}
if (reset) {
lisattavaNumero++;
continue;
} else {
break;
}
}
ruudukko[rivi][sarake] = lisattavaNumero++;
lisattavaNumero = 1;
}
}
StringBuilder rakentaja;
for (int rivi = 0; rivi < n; rivi++) {
rakentaja = new StringBuilder();
for (int sarake = 0; sarake < n; sarake++) {
rakentaja.append(ruudukko[rivi][sarake]);
rakentaja.append(" ");
}
System.out.println(rakentaja.toString());
}
}
}