#include <bits/stdc++.h>
using namespace std;
int n;
bool vis[2020][2];
int a[2020][2020];
int dfs1(int ver, bool f) {
  int ret = 1;
  vis[ver][f] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i][f] && a[ver][i] > 0) ret += dfs1(i, f);
  return ret;
}
int dfs2(int ver, bool f) {
  int ret = 1;
  vis[ver][f] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i][f] && a[i][ver] > 0) ret += dfs2(i, f);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &(a[i][j]));
  if (dfs1(1, 0) == n && dfs2(1, 1) == n)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
