#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
bool row[maxn], col[maxn];
int a[maxn][maxn], mat[maxn][maxn];
int n;
bool check(int u, int d, int l, int r) {
  if (u > d || l > r) return false;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) mat[i][j] = 0;
  for (int i = u; i <= d; i++)
    for (int j = l; j <= r; j++) mat[i][j] = 4;
  for (int i = u; i <= d; i++) {
    if (l - 1 >= 0) mat[i][l - 1] = 2;
    if (r + 1 < n) mat[i][r + 1] = 2;
  }
  for (int i = l; i <= r; i++) {
    if (u - 1 >= 0) mat[u - 1][i] = 2;
    if (d + 1 < n) mat[d + 1][i] = 2;
  }
  if (l > 0 && u > 0) mat[u - 1][l - 1] = 1;
  if (l > 0 && d + 1 < n) mat[d + 1][l - 1] = 1;
  if (r + 1 < n && u > 0) mat[u - 1][r + 1] = 1;
  if (r + 1 < n && d + 1 < n) mat[d + 1][r + 1] = 1;
  bool ok = true;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) ok &= (a[i][j] == mat[i][j]);
  return ok;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = n - 1; i >= 0; i--)
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      a[i][j] = (c - '0');
      if (a[i][j]) row[i] = col[j] = true;
    }
  int u = 0, d = n - 1, l = 0, r = n - 1;
  while (u < n && !row[u]) u++;
  while (d >= 0 && !row[d]) d--;
  while (l < n && !col[l]) l++;
  while (r >= 0 && !col[r]) r--;
  if (u > d || l > r) return (cout << "No\n"), 0;
  int a[4] = {u, d, l, r};
  int add[4] = {1, -1, 1, -1};
  for (int i = 0; i < (1 << 4); i++) {
    int b[4] = {a[0], a[1], a[2], a[3]};
    for (int j = 0; j < 4; j++)
      if ((i >> j) & 1) b[j] += add[j];
    if (check(b[0], b[1], b[2], b[3])) return (cout << "Yes" << endl), 0;
  }
  cout << "No" << endl;
  return 0;
}
