#include <bits/stdc++.h>
using namespace std;
int ar[50][50];
int main() {
  int n;
  cin >> n;
  char c;
  int tlx, tly, brx, bry;
  int found = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c;
      ar[i][j] = c - '0';
      if (ar[i][j] == 4) {
        if (found == 0) {
          tlx = i;
          tly = j;
          found = 1;
        }
        brx = i;
        bry = j;
      }
    }
  }
  for (int i = tlx; i <= brx; i++) {
    for (int j = tly; j <= bry; j++) {
      if (ar[i][j] != 4) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  if ((tlx >= 1 && tly >= 1 && ar[tlx - 1][tly - 1] != 1) ||
      (brx <= n - 2 && bry <= n - 2 && ar[brx + 1][bry + 1] != 1) ||
      (tlx >= 1 && bry <= n - 2 && ar[tlx - 1][bry + 1] != 1) ||
      (brx <= n - 2 && tly >= 1 && ar[brx + 1][tly - 1] != 1) || found == 0) {
    cout << "No" << endl;
    return 0;
  }
  for (int j = tly; j <= bry; j++) {
    if ((tlx >= 1 && ar[tlx - 1][j] != 2) ||
        (brx <= n - 2 && ar[brx + 1][j] != 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = tlx; i <= brx; i++) {
    if ((tly >= 1 && ar[i][tly - 1] != 2) ||
        (bry <= n - 2 && ar[i][bry + 1] != 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (tlx - 1 <= i && i <= brx + 1 && tly - 1 <= j && j <= bry + 1) {
        continue;
      }
      if (ar[i][j] != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
