N=int(input()) G=range(N) T=[[0]*N for j in G] for i in G: Ti=input().split() for j in G: T[i][j]=int(Ti[j]) for i in G: for j in G: for k in G: if T[T[i][j]][k]!=T[i][T[j][k]]: print("No") exit(0) for e in G: u=1 for n in G: if T[e][n]!=n: u=0 break elif T[n][e]!=n: u=0 break if u==1: for n in G: u=0 for i in G: if T[n][i]==e: u=1 break if u==0:break if u==1: print("Yes") exit(0) print("No")