#include <bits/stdc++.h>
using namespace std;
char field[55][55];
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > first;
  for (int i = 0; i < n; ++i) {
    scanf("%*c");
    for (int j = 0; j < n; ++j) {
      scanf("%c", &field[i][j]);
      if (field[i][j] == '4') {
        first.push_back({i, j});
      }
    }
  }
  if (first.size() == 0) {
    printf("No");
    return 0;
  }
  int min_x = 100, max_x = -100, min_y = 100, max_y = -100;
  for (int i = 0; i < (int)first.size(); ++i) {
    min_x = min(min_x, first[i].first);
    max_x = max(max_x, first[i].first);
    min_y = min(min_y, first[i].second);
    max_y = max(max_y, first[i].second);
  }
  ++max_x;
  ++max_y;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int cnt = 0;
      for (int di = 0; di <= 1; ++di) {
        for (int dj = 0; dj <= 1; ++dj) {
          int new_i = i + di;
          int new_j = j + dj;
          if (min_x <= new_i && new_i <= max_x && min_y <= new_j &&
              new_j <= max_y) {
            ++cnt;
          }
        }
      }
      if (cnt != field[i][j] - '0') {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}
