#include <bits/stdc++.h>
using namespace std;
const int N = 310;
int n;
int a[N][N];
int mnx, mny, mxx, mxy;
void update(int x, int y) {
  mnx = min(mnx, x);
  mny = min(mny, y);
  mxx = max(mxx, x);
  mxy = max(mxy, y);
}
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      char c;
      scanf("%c", &c);
      a[i][j] = c - '0';
    }
    scanf("\n");
  }
  mnx = mny = n;
  mxx = mxy = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == 4) {
        update(j, i);
      }
    }
  }
  bool ok = true;
  for (int i = mny; i <= mxy; ++i) {
    for (int j = mnx; j <= mxx; ++j) {
      if (a[i][j] != 4) ok = false;
    }
  }
  if (mnx - 1 >= 0) {
    for (int i = mny; i <= mxy; ++i) {
      if (a[i][mnx - 1] != 2) ok = false;
    }
  }
  if (mxx + 1 < n) {
    for (int i = mny; i <= mxy; ++i) {
      if (a[i][mxx + 1] != 2) ok = false;
    }
  }
  if (mny - 1 >= 0) {
    for (int j = mnx; j <= mxx; ++j) {
      if (a[mny - 1][j] != 2) ok = false;
    }
  }
  if (mxy + 1 < n) {
    for (int j = mnx; j <= mxx; ++j) {
      if (a[mxy + 1][j] != 2) ok = false;
    }
  }
  if (mny - 1 >= 0 && mnx - 1 >= 0 && a[mny - 1][mnx - 1] != 1) ok = false;
  if (mny - 1 >= 0 && mxx + 1 < n && a[mny - 1][mxx + 1] != 1) ok = false;
  if (mxy + 1 < n && mxx + 1 < n && a[mxy + 1][mxx + 1] != 1) ok = false;
  if (mxy + 1 < n && mnx - 1 >= 0 && a[mxy + 1][mnx - 1] != 1) ok = false;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!(i >= mny - 1 && i <= mxy + 1 && j >= mnx - 1 && j <= mxx + 1) &&
          a[i][j] != 0)
        ok = false;
    }
  }
  if (ok == true)
    printf("Yes");
  else
    printf("No");
  return 0;
}
