#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667772160")
using namespace std;
struct __isoff {
  __isoff() {
    if (0) freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
  }
  ~__isoff() {}
} __osafwf;
const unsigned long long p1 = 31;
const unsigned long long p2 = 29;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int infi = 1e9 + 7;
const long long inf = 1e18 + 7;
const long long dd = 5e2 + 7;
const long long mod = 1e9 + 7;
int E[dd][dd], T[dd][dd];
int main() {
  int n;
  cin >> n;
  for (long long i = 0; i < (long long)n; i++) {
    for (long long j = 0; j < (long long)n; j++) {
      char c;
      cin >> c;
      E[i][j] = c - '0';
    }
  }
  int minx, miny, maxx, maxy;
  minx = infi;
  miny = infi;
  maxx = -infi;
  maxy = -infi;
  for (long long i = 0; i < (long long)n; i++) {
    for (long long j = 0; j < (long long)n; j++) {
      if (E[i][j] == 4) {
        minx = min((int)i, minx);
        miny = min((int)j, miny);
        maxx = max((int)i, maxx);
        maxy = max((int)j, maxy);
      }
    }
  }
  if (minx == infi) {
    cout << "No";
    return 0;
  }
  for (int i = minx; i <= maxx; i++) {
    for (int j = miny; j <= maxy; j++) {
      T[i][j] = 4;
    }
  }
  for (int i = minx; i <= maxx; i++) {
    if (miny > 0) T[i][miny - 1] = 2;
    T[i][maxy + 1] = 2;
  }
  for (int i = miny; i <= maxy; i++) {
    if (minx > 0) T[minx - 1][i] = 2;
    T[maxx + 1][i] = 2;
  }
  T[maxx + 1][maxy + 1] = 1;
  if (miny > 0) T[maxx + 1][miny - 1] = 1;
  if (miny > 0 && minx > 0) T[minx - 1][miny - 1] = 1;
  if (minx > 0) T[minx - 1][maxy + 1] = 1;
  for (long long i = 0; i < (long long)n; i++) {
    for (long long j = 0; j < (long long)n; j++) {
      if (T[i][j] != E[i][j]) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
