#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (c < 48) c == '-' && (f = -1), c = getchar();
  while (c > 47) x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int MAXN = 2005;
int G[MAXN][MAXN], dfn[MAXN];
int st[MAXN], vis[MAXN], low[MAXN];
int n, t, sz, top, dft;
inline void tarjan(int x) {
  vis[st[++top] = x] = 1;
  dfn[x] = low[x] = ++dft;
  for (int i = 1; i <= n; ++i)
    if (G[x][i]) {
      if (!dfn[i])
        tarjan(i), low[x] = min(low[x], low[i]);
      else if (vis[i])
        low[x] = min(low[x], dfn[i]);
    }
  if (dfn[x] == low[x] && (sz = 0, 1))
    while (t ^ x) vis[t = st[top--]] = 0, ++sz;
}
int main(int argc, char const *argv[]) {
  n = read();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) G[i][j] = read() > 0;
  tarjan(1);
  puts(sz == n ? "YES" : "NO");
  return 0;
}
