#include <bits/stdc++.h>
using namespace std;
int N;
bitset<2005> A[2005];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      int x;
      scanf("%d", &x);
      A[i][j] = !!x;
    }
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      if (A[i][k]) A[i] |= A[k];
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (!A[i][j]) return puts("NO"), 0;
  puts("YES");
}
