#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 100;
char s[MAX][MAX];
int n;
void clear() {}
void No() { printf("No\n"); }
void solve() {
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int minx = INT_MAX, miny = INT_MAX;
  int maxx = INT_MIN, maxy = INT_MIN;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++)
      if (s[x][y] == '4')
        minx = min(minx, x), maxx = max(maxx, x), miny = min(miny, y),
        maxy = max(maxy, y);
  if (minx == INT_MAX) return No();
  for (int x = minx; x <= maxx; x++)
    for (int y = miny; y <= maxy; y++)
      if (s[x][y] != '4') return No();
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++) {
      int expected = 0;
      if (x >= minx && x <= maxx && y >= miny && y <= maxy)
        expected = 4;
      else if (x >= minx - 1 && x <= maxx + 1 && y >= miny - 1 &&
               y <= maxy + 1) {
        if ((x == minx - 1 || x == maxx + 1) &&
            (y == miny - 1 || y == maxy + 1))
          expected = 1;
        else
          expected = 2;
      } else
        expected = 0;
      if (expected + '0' != s[x][y]) return No();
    }
  printf("Yes\n");
}
int main() {
  while (scanf("%d", &n) == 1) {
    clear();
    solve();
    return 0;
  }
  return 0;
}
