#include <bits/stdc++.h>
bool visit[2007], e[2007][2007], instk[2007], ok = true;
int low[2007], dfn[2007], stk[2007], top = -1, cnt = 0, n;
using namespace std;
void tarjan(int x) {
  visit[x] = true;
  low[x] = dfn[x] = ++cnt;
  instk[x] = true;
  stk[++top] = x;
  for (int i = 0; i < n; i++)
    if (e[x][i]) {
      if (!visit[i]) {
        tarjan(i);
        low[x] = min(low[x], low[i]);
      } else if (instk[i])
        low[x] = min(low[x], low[i]);
    }
  if (low[x] == dfn[x]) {
    if (x != 0) ok = false;
    while (stk[top] != x) instk[stk[top--]] = false;
    instk[stk[top--]] = false;
  }
}
int main() {
  int x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &x);
      e[i][j] = x;
    }
  tarjan(0);
  for (int i = 0; i < n; i++)
    if (!visit[i]) ok = false;
  printf(ok ? "YES\n" : "NO\n");
  return 0;
}
