#include <bits/stdc++.h>
using namespace std;
int g[2010][2010];
int low[2010], n, dfs_clock, sccno[2010], pre[2010], scc_cnt;
stack<int> st;
void dfs(int u) {
  pre[u] = low[u] = ++dfs_clock;
  st.push(u);
  for (int v = 1; v <= n; v++)
    if (g[u][v]) {
      if (!pre[v]) {
        dfs(v);
        low[u] = min(low[u], low[v]);
      } else if (!sccno[v]) {
        low[u] = min(low[u], pre[v]);
      }
    }
  if (low[u] == pre[u]) {
    scc_cnt++;
    sccno[u] = 1;
    while (st.top() != u) {
      sccno[st.top()] = scc_cnt;
      st.pop();
    }
    sccno[st.top()] = scc_cnt;
    st.pop();
    if (scc_cnt > 1) {
      puts("NO");
      exit(0);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &g[i][j]);
  for (int i = 1; i <= n; i++)
    if (!pre[i]) dfs(i);
  puts("YES");
  return 0;
}
