#include <bits/stdc++.h>
using namespace std;
int lx[4] = {0, -1, -1, 0};
int ly[4] = {0, -1, 0, -1};
int a[55][55], mark[55][55];
char st[55];
int main() {
  int n;
  scanf("%d", &n);
  int up = n + 1, down = -1, left = n + 1, right = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%s", st + 1);
    for (int j = 1; j <= n; j++) {
      a[i][j] = st[j] - '0';
      if (a[i][j] == 4) {
        for (int k = 0; k < 4; k++) {
          int x = i + lx[k], y = j + ly[k];
          mark[x][y] = 1;
          up = min(up, x);
          down = max(down, x);
          left = min(left, y);
          right = max(right, y);
        }
      }
    }
  }
  if (up >= down || left >= right) {
    printf("No\n");
    return 0;
  }
  for (int i = up; i <= down; i++)
    for (int j = left; j <= right; j++)
      if (!mark[i][j]) {
        printf("No\n");
        return 0;
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < 4; k++) {
        int x = i + lx[k], y = j + ly[k];
        a[i][j] -= mark[x][y];
      }
      if (a[i][j] != 0) {
        printf("No\n");
        return 0;
      }
    }
  printf("Yes\n");
  return 0;
}
