#include <bits/stdc++.h>
using namespace std;
int V;
vector<int> G[2005];
vector<int> rG[2005];
vector<int> vs;
bool used[2005];
int cmp[2005];
void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}
void dfs(int v) {
  int i;
  used[v] = 1;
  for (i = 0; i < G[v].size(); i++)
    if (!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k) {
  int i;
  used[v] = 1;
  cmp[v] = k;
  for (i = 0; i < rG[v].size(); i++)
    if (!used[rG[v][i]]) rdfs(rG[v][i], k);
}
int scc() {
  int i, k;
  memset(used, 0, sizeof(used));
  vs.clear();
  for (i = 0; i < V; i++)
    if (!used[i]) dfs(i);
  memset(used, 0, sizeof(used));
  k = 0;
  for (i = vs.size() - 1; i >= 0; i--)
    if (!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
int main() {
  int i, j, ans, num;
  while (scanf("%d", &V) != EOF) {
    for (i = 0; i < V; i++) G[i].clear();
    for (i = 0; i < V; i++)
      for (j = 0; j < V; j++) {
        scanf("%d", &num);
        if (num) add_edge(i, j);
      }
    ans = scc();
    if (ans == 1)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
