import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
{
Scanner in
= new Scanner
(System.
in); int n = in.nextInt();
int a[][] = new int[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
a[i][j] = in.nextInt();
if ((i == j) && (a[i][j] == 1)) {
return;
}
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if (a[i][j] != a[j][i]) {
return;
}
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpwdWJsaWMgY2xhc3MgTWFpbgp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSAgdGhyb3dzIElPRXhjZXB0aW9uCgl7CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJaW50IG4gPSBpbi5uZXh0SW50KCk7CgkJaW50IGFbXVtdID0gbmV3IGludFtuXVtuXTsKCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CgkJCWZvcihpbnQgaiA9IDA7IGogPCBuOyBqKyspIHsKCQkJCWFbaV1bal0gPSBpbi5uZXh0SW50KCk7CgkJCQlpZiAoKGkgPT0gaikgJiYgKGFbaV1bal0gPT0gMSkpIHsKCQkJCQlTeXN0ZW0ub3V0LnByaW50KCJOTyIpOwoJCQkJCXJldHVybjsKCQkJCX0KCQkJfQoJCX0KCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CgkJCWZvcihpbnQgaiA9IDA7IGogPCBuOyBqKyspIHsKCQkJCWlmIChhW2ldW2pdICE9IGFbal1baV0pIHsKCQkJCQlTeXN0ZW0ub3V0LnByaW50KCJOTyIpOwoJCQkJCXJldHVybjsKCQkJCX0KCQkJfQoJCX0KCQlTeXN0ZW0ub3V0LnByaW50KCJZRVMiKTsKCX0KfQ==