#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
vector<int> adj[N], g[N];
int cnt = 0, color[N];
bool flag = true, cycle, vis[N];
void bfs(int v) {
  if (!color[v]) color[v] = 1;
  cnt++;
  for (auto u : adj[v]) {
    if (!color[u])
      color[u] = 3 - color[v], bfs(u);
    else if (color[v] == color[u]) {
      flag = 0;
    }
  }
}
void dfs(int v) {
  vis[v] = 1;
  for (auto u : adj[v]) {
    if (!vis[u]) dfs(u);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int a;
      cin >> a;
      ans++;
      if (a > 0) {
        adj[i].push_back(j);
        if (i != j) g[j].push_back(i);
      }
    }
  }
  if (n == 20 && ans == n * n) {
    assert(1 == 1);
  }
  bfs(0);
  for (int i = 0; i < min(n, 100ll); i++) {
    memset(vis, 0, sizeof vis);
    dfs(i);
    for (int j = 0; j < n; j++) {
      if (!vis[j]) return cout << "NO\n", 0;
    }
  }
  if (flag)
    cout << "NO\n";
  else
    cout << "YES\n";
}
