import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = sc.nextInt(); } } sc.close(); boolean[] ek = new boolean[n]; Arrays.fill(ek, true); for (int m = 0; m < n; m++) { for (int e = 0; e < n; e++) { if (a[m][e] == a[e][m] && a[m][e] == m) { } else { ek[e] = false; } } } for (int e = 0; e < n; e++) { if (ek[e]) { boolean flga = true; for (int m = 0; m < n; m++) { boolean flg = false; for (int i = 0; i < n; i++) { if (a[m][i] == a[i][m] && a[m][i] == e) { flg = true; break; } } if (!flg) { flga = false; break; } } if (flga) { System.out.println("Yes"); return; } } } System.out.println("No"); } }