#include <bits/stdc++.h>
using namespace std;
unsigned long long a[2000][2000 / 63 + 1], p[63];
int b[2000], c[2000], n, t, i, j, k, nn;
bool f;
int main() {
  scanf("%d", &n);
  nn = n / 63 + 1;
  for (i = 0; i < 63; i++) p[i] = 1ULL << i;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      scanf("%d", &t);
      if (t) a[i][j / 63] |= p[j % 63];
    }
  for (k = 0; k < n; k++)
    for (i = 0; i < n; i++)
      if (a[i][k / 63] & p[k % 63])
        for (j = 0; j < nn; j++) a[i][j] |= a[k][j];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (a[i][j / 63] & p[j % 63]) ++b[i], ++c[j];
  for (i = 0; !f && i < n; i++)
    if (b[i] == n && c[i] == n) f = 1;
  cout << (f ? "YES" : "NO") << endl;
  return 0;
}
