#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> G(N);
  for (int x = 0; x < N; x++) cin >> G[x];
  vector<pair<int, int> > P;
  for (int x = 0; x < N; x++) {
    int start = 0, cnt = 0;
    bool ended = false, outer = false;
    for (int y = 0; y < N; y++) {
      if (G[x][y] == '3') {
        cout << "No\n";
        return 0;
      }
      if (ended && G[x][y] != '0') outer = true;
      if (start && !ended &&
          (((G[x][y] != '4' && G[x][y] != '2') && start == 2) ||
           ((G[x][y] != '2' && G[x][y] != '1') && start == 1))) {
        cout << "No\n";
        return 0;
      }
      if (start && G[x][y] - '0' == start) ended = true;
      if (!start && G[x][y] != '0') start = G[x][y] - '0';
      cnt += start != 0 && !ended;
    }
    if ((ended == false || outer) && start) {
      cout << "No\n";
      return 0;
    }
    if (start) P.push_back({start, cnt + 1});
  }
  if (P.empty() || P[0].second == 2) {
    cout << "No\n";
    return 0;
  }
  bool same_width = true;
  for (int x = 0; x < P.size(); x++) same_width &= P[x].second == P[0].second;
  bool valid = P[0].first == 1 && P.back().first == 1;
  for (int i = 1; i + 1 < P.size(); i++) valid &= P[i].first == 2;
  cout << (same_width && valid ? "Yes\n" : "No\n");
}
