#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
const int MAX = 52;
const int INF = 1000000001;
int n;
int a[MAX][MAX];
int board[MAX][MAX];
bool check() {
  int nonZero = 0;
  for (int row = 0; row < n; row++)
    for (int col = 0; col < n; col++)
      if (a[row][col] != 0) nonZero++;
  int srow = INF, erow = -INF;
  int scol = INF, ecol = -INF;
  for (int row = 0; row < n; row++) {
    for (int col = 0; col < n; col++) {
      if (a[row][col] == 4) {
        if (srow > row)
          srow = row, scol = col;
        else if (srow == row && scol > col)
          srow = row, scol = col;
        if (erow < row)
          erow = row, ecol = col;
        else if (erow == row && ecol < col)
          erow = row, ecol = col;
      }
    }
  }
  for (int row = 0; row < n; row++) {
    for (int col = 0; col < n; col++) {
      if (row + 1 < srow) continue;
      if (row - 1 > erow) continue;
      if (col + 1 < scol) continue;
      if (col - 1 > ecol) continue;
      if (row >= srow && row <= erow && col >= scol && col <= ecol) {
        board[row][col] = 4;
      } else if (row >= srow && row <= erow &&
                 (col + 1 == scol || col - 1 == ecol)) {
        board[row][col] = 2;
      } else if (col >= scol && col <= ecol &&
                 (row + 1 == srow || row - 1 == erow)) {
        board[row][col] = 2;
      } else if (row + 1 == srow && col + 1 == scol) {
        board[row][col] = 1;
      } else if (row + 1 == srow && col - 1 == ecol) {
        board[row][col] = 1;
      } else if (row - 1 == erow && col + 1 == scol) {
        board[row][col] = 1;
      } else if (row - 1 == erow && col - 1 == ecol) {
        board[row][col] = 1;
      }
    }
  }
  for (int row = 0; row < n; row++) {
    for (int col = 0; col < n; col++) {
      if (a[row][col] != board[row][col]) return false;
    }
  }
  return true;
}
int main(void) {
  in = stdin;
  out = stdout;
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) {
    char buff[MAX];
    fscanf(in, "%s", buff);
    for (int c = 0; c < n; c++) a[i][c] = buff[c] - '0';
  }
  fprintf(out, "%s\n", check() ? "Yes" : "No");
  return 0;
}
