#include <bits/stdc++.h>
using namespace std;
int t[60][60];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  ifstream in("input.txt");
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int k = 0; k < n; k++) {
      t[i][k] = s[k] - '0';
    }
  }
  int imin = 100, imax = -1;
  int kmin = 100, kmax = -1;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      if (t[i][k] > 0) {
        imin = min(imin, i);
        imax = max(imax, i);
        kmin = min(kmin, k);
        kmax = max(kmax, k);
        tot++;
      }
    }
  }
  if (imin >= imax || kmin >= kmax) {
    cout << "No";
    return 0;
  }
  for (int i = imin; i <= imax; i++) {
    for (int k = kmin; k <= kmax; k++) {
      int situation = (i == imin) + (i == imax) + (k == kmin) + (k == kmax);
      if ((situation == 2) && (t[i][k] != 1)) {
        cout << "No";
        return 0;
      }
      if ((situation == 1) && (t[i][k] != 2)) {
        cout << "No";
        return 0;
      }
      if ((situation == 0) && (t[i][k] != 4)) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
