#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int MAXN = 55;
int n;
char c[MAXN][MAXN];
bool check(pair<int, int> a, pair<int, int> b) {
  int test[MAXN][MAXN];
  memset(test, 0, sizeof test);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i >= a.first && i <= b.first && j >= a.second && j <= b.second) {
        test[i][j] = 4;
      }
      if ((i + 1 == a.first || i - 1 == b.first) &&
              (j >= a.second && j <= b.second) ||
          (j + 1 == a.second || j - 1 == b.second) &&
              (i >= a.first && i <= b.first)) {
        test[i][j] = 2;
      }
      if ((i + 1 == a.first || i - 1 == b.first)) {
        if ((j + 1 == a.second || j - 1 == b.second)) {
          test[i][j] = 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int t = 0; t < n; t++)
      if (c[i][t] != test[i][t]) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", c[i]);
    for (int j = 0; j < n; j++) c[i][j] -= '0';
  }
  pair<int, int> first = {-1, -1}, last = {-1, -1};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (c[i][j] == 4) {
        last = {i, j};
        if (first.first == -1) first = {i, j};
      }
    }
  }
  if (check(first, last))
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
