#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
int n;
int tmp[MAXN][MAXN];
int m[MAXN][MAXN];
int bio[MAXN];
int visit(int x) {
  bio[x] = 1;
  int ret = 1;
  for (int i = 0; i < n; ++i)
    if (m[x][i] && !bio[i]) ret += visit(i);
  return ret;
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &m[i][j]);
  int p = visit(0);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) tmp[i][j] = m[j][i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) m[i][j] = tmp[i][j];
  memset(bio, 0, sizeof bio);
  p += visit(0);
  if (p == 2 * n)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
