#include <bits/stdc++.h>
using namespace std;
int N;
bool inside(int first, int second) {
  return first >= 0 && second >= 0 && first < N && second < N;
}
bool solve() {
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < int(N); ++i) cin >> s[i];
  vector<pair<int, int>> s4;
  for (int first = 0; first < int(N); ++first)
    for (int second = 0; second < int(N); ++second) {
      if (s[first][second] == '3') return false;
      if (s[first][second] == '4') s4.push_back({first, second});
    }
  if (s4.size() == 0) return false;
  sort(s4.begin(), s4.end());
  int x1, x2, y1, y2, S4 = s4.size() - 1;
  y1 = s4[0].first;
  x1 = s4[0].second;
  y2 = s4[S4].first;
  x2 = s4[S4].second;
  bool check = true;
  for (int first = 0; first < int(N); ++first)
    for (int second = 0; second < int(N); ++second) {
      if (first == y1 - 1 || first == y2 + 1) {
        if (second == x1 - 1 || second == x2 + 1) {
          check &= s[first][second] == '1';
        } else if (second >= x1 && second <= x2) {
          check &= s[first][second] == '2';
        } else {
          check &= s[first][second] == '0';
        }
      } else if (second == x1 - 1 || second == x2 + 1) {
        if (first == y1 - 1 || first == y2 + 1) {
          check &= s[first][second] == '1';
        } else if (first >= y1 && first <= y2) {
          check &= s[first][second] == '2';
        } else {
          check &= s[first][second] == '0';
        }
      } else if (second >= x1 && second <= x2 && first >= y1 && first <= y2) {
        check &= s[first][second] == '4';
      } else {
        check &= s[first][second] == '0';
      }
    }
  return check;
}
int main(void) {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}
