#include <bits/stdc++.h>
using namespace std;
void _dbg(string) { cout << endl; }
template <class H, class... T>
void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
bool solve() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> vec[i];
  int sx = -1, sy = -1, tx = -1, ty = -1;
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(n); j++)
      if (vec[i][j] == '4') {
        sx = i;
        sy = j;
        i = n;
        j = n;
      }
  if (sx == -1 || sy == -1) return false;
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(n); j++)
      if (vec[i][j] == '4') {
        tx = i;
        ty = j;
      }
  auto in = [&](int i, int j) { return i >= 0 && j >= 0 && i < n && j < n; };
  bool flg = true;
  auto ch = [&](int i, int j, int p) {
    if (in(i, j)) {
      if (vec[i][j] != p + '0')
        flg = false;
      else
        vec[i][j] = '0';
    }
  };
  for (int i = sx; i <= tx; i++) {
    for (int j = sy; j <= ty; j++) {
      ch(i, j, 4);
    }
  }
  for (int i = sx; i <= tx; i++) {
    ch(i, sy - 1, 2);
    ch(i, ty + 1, 2);
  }
  for (int j = sy; j <= ty; j++) {
    ch(sx - 1, j, 2);
    ch(tx + 1, j, 2);
  }
  int xx[] = {sx - 1, tx + 1};
  int yy[] = {sy - 1, ty + 1};
  for (int i = (int)(0); i < (int)(2); i++)
    for (int j = (int)(0); j < (int)(2); j++) {
      ch(xx[i], yy[j], 1);
    }
  if (!flg) return false;
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(n); j++)
      if (vec[i][j] != '0') return false;
  return true;
}
int main() {
  if (solve())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
