#include <bits/stdc++.h>
using namespace std;
char bb[55][55];
char aa[55][55];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", bb[i]);
  int a = 100;
  int b = -1;
  int c = 100;
  int d = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (bb[i][j] == '4') {
        a = min(a, j);
        b = max(b, j);
        c = min(c, i);
        d = max(d, i);
      }
    }
  }
  if (a > b) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      aa[i][j] = '0';
      for (int k = 0; k < 2; k++)
        for (int m = 0; m < 2; m++) {
          int p = i + k, q = j + m;
          if (a <= q && q <= b + 1 && c <= p && p <= d + 1) {
            aa[i][j]++;
          }
        }
      if (aa[i][j] != bb[i][j]) {
        printf("No\n");
        return 0;
      }
    }
  printf("Yes\n");
}
