#include <bits/stdc++.h>
using namespace std;
int a[55][55], n, tot = 0, sx, sy, flag = 1, use[55][55];
int mx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int my[] = {0, 1, 0, -1, -1, 1, 1, -1};
int jud(int x, int y) { return x >= 0 && y >= 0 && x < n && y < n; }
void dfs(int x, int y) {
  use[x][y] = 1;
  tot--;
  for (int i = 0; i < 4; i++) {
    int nx = x + mx[i];
    int ny = y + my[i];
    if (jud(nx, ny) && !use[nx][ny] && a[nx][ny] == 4) dfs(nx, ny);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%1d", &a[i][j]);
      if (a[i][j] == 4) tot++, sx = i, sy = j;
    }
  dfs(sx, sy);
  flag = 0;
  if (!tot) {
    flag = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (a[i][j] != 4) {
          int du[4] = {0};
          for (int k = 0; k < 4; k++) {
            int nx = i + mx[k];
            int ny = j + my[k];
            if (jud(nx, ny) && a[nx][ny] == 4) du[k] = du[(k + 5) % 4] = 1;
          }
          for (int k = 4; k < 8; k++) {
            int nx = i + mx[k];
            int ny = j + my[k];
            if (jud(nx, ny) && a[nx][ny] == 4) du[k - 4] = 1;
          }
          int t = 0;
          for (int k = 0; k < 4; k++) t += du[k];
          if (t != a[i][j]) {
            flag = 0;
            break;
          }
        }
  }
  if (flag)
    puts("yes");
  else
    puts("no");
  return 0;
}
