#include <bits/stdc++.h>
using namespace std;
int main(int, char**) {
  int n = 0;
  cin >> n;
  vector<vector<short> > m(n, vector<short>(n, 0));
  int nones = 0;
  int nfour = 0;
  int i0 = 1e6, i1 = -1e6, j0 = 1e6, j1 = -1e6;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      m[i][j] = c - '0';
      if (m[i][j] == 4) {
        ++nfour;
      }
      if (m[i][j] == 1) {
        ++nones;
        i0 = min(i, i0);
        j0 = min(j, j0);
        i1 = max(i, i1);
        j1 = max(j, j1);
      }
    }
  if (nones > 4 || nfour == 0) {
    cout << "No";
    return 0;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (i > i1 || i < i0 || j > j1 || j < j0)
        if (m[i][j] != 0) {
          cout << "No";
          return 0;
        }
      if (((i == i0 || i == i1) && j > j0 && j < j1) ||
          ((j == j0 || j == j1) && i > i0 && i < i1)) {
        if (m[i][j] != 2) {
          cout << "No";
          return 0;
        }
      }
      if (i < i1 && i > i0 && j < j1 && j > j0)
        if (m[i][j] != 4) {
          cout << "No";
          return 0;
        }
    }
  cout << "Yes";
  return 0;
}
