#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
void kill(bool b) {
  puts(b ? "Yes" : "No");
  exit(0);
}
void ifkill(bool cond, bool b) {
  if (cond) {
    kill(b);
  }
}
int N, A[MAXN][MAXN];
bool out(int x, int y) { return x < 0 || x >= N || y < 0 || y >= N; }
int main() {
  scanf("%d", &N);
  int minx4 = MAXN, maxx4 = -1, miny4 = MAXN, maxy4 = -1;
  for (int i = 0; i < N; i++) {
    getchar();
    for (int j = 0; j < N; j++) {
      A[i][j] = getchar() - '0';
      if (A[i][j] == 4) {
        minx4 = min(minx4, i);
        maxx4 = max(maxx4, i);
        miny4 = min(miny4, j);
        maxy4 = max(maxy4, j);
      }
    }
  }
  ifkill(maxy4 == -1, false);
  for (int i = minx4 - 1; i <= maxx4 + 1; i++) {
    bool bordi = (i == minx4 - 1 || i == maxx4 + 1);
    for (int j = miny4 - 1; j <= maxy4 + 1; j++) {
      bool bordj = (j == miny4 - 1 || j == maxy4 + 1);
      if (bordi ^ bordj) {
        ifkill((!out(i, j) && A[i][j] != 2), false);
      } else if (bordi) {
        ifkill((!out(i, j) && A[i][j] != 1), false);
      } else {
        ifkill((!out(i, j) && A[i][j] != 4), false);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (!(minx4 - 1 <= i && i <= maxx4 + 1 && miny4 - 1 <= j &&
            j <= maxy4 + 1)) {
        ifkill(A[i][j] != 0, false);
      }
    }
  }
  kill(true);
}
