#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int n, ans[60][60], grid[60][60], dr[] = {0, 0, 1, 1, 1, -1, -1, -1},
                                  dc[] = {-1, 1, -1, 0, 1, -1, 0, 1},
                                  dv[] = {2, 2, 1, 2, 1, 1, 2, 1};
char g[60][60];
int fr, fc, w = 0, h = 0;
bool valid(int r, int c) { return (r >= 0 && r < n && c < n && c >= 0); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", g[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) grid[i][j] = g[i][j] - '0';
  int f = 1;
  for (int i = 0; i < n && f; i++) {
    for (int j = 0; j < n && f; j++) {
      if (grid[i][j] == 4) {
        f = 0;
        fr = i;
        fc = j;
      }
    }
  }
  if (f) {
    puts("No");
    return 0;
  }
  for (; fc + w < n; w++)
    if (grid[fr][fc + w] != 4) break;
  for (; fr + h < n; h++)
    if (grid[fr + h][fc] != 4) break;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[fr + i][fc + j] != 4) {
        puts("No");
        return 0;
      }
      ans[fr + i][fc + j] = 4;
      for (int a = 0; a < 8; a++) {
        int r, c;
        r = fr + i + dr[a];
        c = fc + j + dc[a];
        if (valid(r, c)) ans[r][c] = max(ans[r][c], dv[a]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (ans[i][j] != grid[i][j]) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}
