#include <bits/stdc++.h>
using namespace std;
int const N = 2000 + 20;
int n;
vector<int> adj[N], rev[N];
bool mark1[N], mark2[N], resM[N];
void dfs1(int v) {
  mark1[v] = 1;
  for (auto u : adj[v])
    if (!mark1[u]) dfs1(u);
  return;
}
void dfs2(int v) {
  mark2[v] = 1;
  for (auto u : rev[v])
    if (!mark2[u]) dfs2(u);
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      if (x) {
        adj[i].push_back(j);
        rev[j].push_back(i);
      }
    }
  }
  dfs1(0);
  dfs2(0);
  for (int i = 0; i < n; i++) resM[i] = mark1[i] & mark2[i];
  for (int i = 0; i < n; i++)
    if (!resM[i]) return printf("NO"), 0;
  return printf("YES"), 0;
}
