#include <bits/stdc++.h>
using namespace std;
int N;
int bio[2005], cookie;
int a[2005][2005];
int last = -1;
int dfs1(int n) {
  if (bio[n] == cookie) return 0;
  bio[n] = cookie;
  int ret = 1;
  for (int i = 0; i < N; ++i)
    if (a[n][i]) ret += dfs1(i);
  return ret;
}
int dfs2(int n) {
  if (bio[n] == cookie) return 0;
  bio[n] = cookie;
  int ret = 1;
  for (int i = 0; i < N; ++i)
    if (a[i][n]) ret += dfs2(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", &a[i][j]);
  ++cookie;
  if (dfs1(0) != N) {
    puts("NO");
    return 0;
  }
  ++cookie;
  if (dfs2(0) != N) {
    puts("NO");
    return 0;
  }
  puts("YES");
  return 0;
}
