#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
int n, a[MAXN][MAXN], b[MAXN][MAXN], cnt, bio[MAXN];
void dfs(int x) {
  if (bio[x]) return;
  bio[x] = 1;
  ++cnt;
  for (int i = 0; i < n; ++i) {
    if (a[x][i]) dfs(i);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  int ok = 1;
  dfs(0);
  ok &= (cnt == n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) b[i][j] = a[j][i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) a[i][j] = b[i][j];
  cnt = 0;
  memset(bio, 0, sizeof bio);
  dfs(0);
  ok &= (cnt == n);
  printf("%s\n", ok ? "YES" : "NO");
  return 0;
}
