#include <bits/stdc++.h>
using namespace std;
char a[107][107];
bool check(int x, int y, int xl, int yl, int xr, int yr) {
  return x >= xl && x <= xr && y >= yl && y <= yr;
}
int main() {
  int n;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", &a[i]);
  }
  int xl = n + 1, xr = -n, yl = n + 1, yr = -n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == '4') {
        xl = min(xl, i);
        xr = max(xr, i + 1);
        yl = min(yl, j);
        yr = max(yr, j + 1);
      }
    }
  }
  if (xl > xr) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int cur = 0;
      if (check(i, j, xl, yl, xr, yr)) cur++;
      if (check(i + 1, j, xl, yl, xr, yr)) cur++;
      if (check(i, j + 1, xl, yl, xr, yr)) cur++;
      if (check(i + 1, j + 1, xl, yl, xr, yr)) cur++;
      if (cur != a[i][j] - '0') {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}
