#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<int> > cont;
bool solve() {
  pair<int, int> f = {-1, -1};
  pair<int, int> l = {-1, -1};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (cont[i][j] == 4) {
        if (f.first == -1) {
          f = {i, j};
        }
        l = {i, j};
      }
    }
  }
  cerr << "Found the lair" << endl;
  cerr << f.first << ", " << f.second << " to " << l.first << ", " << l.second
       << endl;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i < f.first || i > l.first || j < f.second || j > l.second) {
        if (cont[i][j] == 4) return false;
      } else {
        if (cont[i][j] != 4) return false;
      }
    }
  }
  cerr << "Checked lair shape" << endl;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i >= f.first && i <= l.first && j >= f.second && j <= l.second)
        continue;
      if ((i == f.first - 1 && j == f.second - 1) ||
          (i == l.first + 1 && j == f.second - 1) ||
          (i == f.first - 1 && j == l.second + 1) ||
          (i == l.first + 1 && j == l.second + 1)) {
        if (cont[i][j] != 1) {
          cerr << "Corner not equal to 1 at " << i << ", " << j << endl;
          return false;
        }
      } else if ((i >= f.first && i <= l.first &&
                  (j == f.second - 1 || j == l.second + 1)) ||
                 (j >= f.second && j <= l.second &&
                  (i == f.first - 1 || i == l.first + 1))) {
        if (cont[i][j] != 2) {
          cerr << "Side not equal to 2 at " << i << ", " << j << endl;
          return false;
        }
      } else if (cont[i][j] != 0) {
        cerr << "Unexpected non-zero at " << i << ", " << j << endl;
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> N;
  cont.assign(N, vector<int>(N));
  char c;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> c;
      cont[i][j] = (c - '0');
    }
  }
  bool ans = solve();
  cout << (ans ? "Yes" : "No") << endl;
}
