#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
int n;
int grid[55][55];
bool conferedirbai(int xi, int yi, int xf, int yf, int i, int j) {
  if (i <= xf and i >= (xi - 1) and j <= yf and j >= (yi - 1)) return true;
  return false;
}
bool confereesqbai(int xi, int yi, int xf, int yf, int i, int j) {
  if (i <= xf and i >= (xi - 1) and j <= yf + 1 and j >= (yi)) return true;
  return false;
}
bool conferedircim(int xi, int yi, int xf, int yf, int i, int j) {
  if (i <= xf + 1 and i >= xi and j <= yf and j >= (yi - 1)) return true;
  return false;
}
bool confereesqcim(int xi, int yi, int xf, int yf, int i, int j) {
  if (i <= xf + 1 and i >= (xi) and j <= yf + 1 and j >= (yi)) return true;
  return false;
}
bool tenta(int xi, int yi, int xf, int yf) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int tmp = 0;
      if (conferedirbai(xi, yi, xf, yf, i, j)) {
        tmp++;
      }
      if (conferedircim(xi, yi, xf, yf, i, j)) {
        tmp++;
      }
      if (confereesqbai(xi, yi, xf, yf, i, j)) {
        tmp++;
      }
      if (confereesqcim(xi, yi, xf, yf, i, j)) {
        tmp++;
      }
      if (tmp != grid[i][j]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char aux;
      cin >> aux;
      grid[i][j] = aux - '0';
    }
  }
  int aux = 0;
  int xii = 60, yii = 60, x2i = 0, y2i = 0;
  for (int xi = 0; xi < n; xi++) {
    for (int y = 0; y < n; y++) {
      if (grid[xi][y] == 4) {
        xii = min(xii, xi);
        x2i = max(x2i, xi);
        yii = min(yii, y);
        y2i = max(y2i, y);
      }
    }
  }
  if (yii != 60 and tenta(xii, yii, x2i, y2i)) {
    cout << "Yes"
         << "\n";
    return 0;
  }
  cout << "No"
       << "\n";
  return 0;
}
