#include <bits/stdc++.h>
using namespace std;
const int N = 64;
char a[N][N];
int n;
bool between(int x, int l, int r) { return x >= l && x <= r; }
void check(char a, char b) {
  if (a != b) {
    cout << "No" << endl;
    exit(0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) scanf("%s", a[i]);
  int maxX = -N, maxY = -N, minX = N, minY = N;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++)
      if (a[i][j] == '4') {
        maxX = max(maxX, i);
        maxY = max(maxY, j);
        minX = min(minX, i);
        minY = min(minY, j);
      }
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) {
      if (between(i, minX, maxX) && between(j, minY, maxY))
        check(a[i][j], '4');
      else if (between(i, minX, maxX) && (j == minY - 1 || j == maxY + 1))
        check(a[i][j], '2');
      else if (between(j, minY, maxY) && (i == minX - 1 || i == maxX + 1))
        check(a[i][j], '2');
      else if (pair<int, int>(i, j) == pair<int, int>(minX - 1, minY - 1))
        check(a[i][j], '1');
      else if (pair<int, int>(i, j) == pair<int, int>(minX - 1, maxY + 1))
        check(a[i][j], '1');
      else if (pair<int, int>(i, j) == pair<int, int>(maxX + 1, minY - 1))
        check(a[i][j], '1');
      else if (pair<int, int>(i, j) == pair<int, int>(maxX + 1, maxY + 1))
        check(a[i][j], '1');
      else
        check(a[i][j], '0');
    }
  cout << "Yes" << endl;
  return 0;
}
