#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int mp[2111][2111], vis[2111], v1[2111], v2[2111];
void dfs1(int x) {
  vis[x] = 1;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (!vis[i] && mp[x][i]) {
      v1[i] = 1, dfs1(i);
    }
  }
}
void dfs2(int x) {
  vis[x] = 1;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (!vis[i] && mp[i][x]) {
      v2[i] = 1, dfs2(i);
    }
  }
}
int main() {
  int t, x, y, z, ca = 1;
  scanf("%d", &(n));
  for (int i = (int)(1); i <= (int)(n); ++i)
    for (int j = (int)(1); j <= (int)(n); ++j) {
      scanf("%d", &(mp[i][j]));
    }
  int st = 0;
  for (int i = (int)(1); i <= (int)(n); ++i)
    if (mp[i][i]) st = i;
  v1[st] = v2[st] = 1;
  dfs1(st);
  memset(vis, 0, sizeof(vis));
  dfs2(st);
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (!(v1[i] && v2[i])) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
