#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
long long N;
long long A[55][55];
signed main() {
  cin >> N;
  bool ex = false;
  for (long long i = 0; i < (N); i++)
    for (long long j = 0; j < (N); j++) {
      char c;
      cin >> c;
      A[i][j] = c - '0';
      if (A[i][j]) ex = true;
    }
  if (!ex) {
    cout << "No" << endl;
    return 0;
  }
  long long min_y = 11111, max_y = -11111, min_x = 11111, max_x = -11111;
  for (long long i = 0; i < (N); i++)
    for (long long j = 0; j < (N); j++) {
      if (A[i][j]) {
        chmin(min_y, i);
        chmax(max_y, i);
        chmin(min_x, j);
        chmax(max_x, j);
      }
    }
  min_x++;
  min_y++;
  for (long long i = 0; i < (N); i++)
    for (long long j = 0; j < (N); j++) {
      for (long long dy = 0; dy <= 1; dy++) {
        for (long long dx = 0; dx <= 1; dx++) {
          long long y = i + dy, x = j + dx;
          if (y < 0 || y > N || x < 0 || x > N) continue;
          if (min_y <= y && y <= max_y && min_x <= x && x <= max_x) A[i][j]--;
        }
      }
      if (A[i][j] != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  cout << "Yes" << endl;
}
