#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <class T>
int sgn(T x) {
  return x > 0 ? 1 : (x < 0 ? -1 : 0);
}
const long double pi = 2 * asinl((long double)1.0);
int n;
int m;
char a[100][100];
int main() {
  scanf("%d ", &n);
  int minx = n, maxx = -1, miny = n, maxy = -1;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    gets(a[i]);
    for (int j = 0; j < n; j++) {
      if (a[i][j] == '4') {
        minx = min(minx, j - 1);
        maxx = max(maxx, j + 1);
        miny = min(miny, i - 1);
        maxy = max(maxy, i + 1);
        ok = true;
      } else if (a[i][j] == '1' || a[i][j] == '2') {
        minx = min(minx, j);
        maxx = max(maxx, j);
        miny = min(miny, i);
        maxy = max(maxy, i);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i > miny && i < maxy && j > minx && j < maxx) {
        ok &= a[i][j] == '4';
      } else if ((i == miny && j == minx) || (i == miny && j == maxx) ||
                 (i == maxy && j == minx) || (i == maxy && j == maxx)) {
        ok &= a[i][j] == '1';
      } else if (i < miny || i > maxy || j < minx || j > maxx) {
        ok &= a[i][j] == '0';
      } else {
        ok &= a[i][j] == '2';
      }
    }
  }
  if (ok)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
