#include <bits/stdc++.h>
using namespace std;
char x;
int a[51][51];
int main() {
  int n;
  cin >> n;
  int x1 = n, x2 = -1, y1 = n, y2 = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> x;
      a[i][j] = x - '0';
      if (a[i][j] != 0) {
        x1 = min(x1, i);
        x2 = max(x2, i);
        y1 = min(y1, j);
        y2 = max(y2, j);
      }
    }
  }
  if (a[x1][y1] != 1 || a[x1][y2] != 1 || a[x2][y1] != 1 || a[x2][y2] != 1) {
    cout << "No";
    return 0;
  };
  for (int i = x1 + 1; i < x2; ++i)
    if (a[i][y1] != 2 || a[i][y2] != 2) {
      cout << "No";
      return 0;
    };
  for (int i = y1 + 1; i < y2; ++i)
    if (a[x1][i] != 2 || a[x2][i] != 2) {
      cout << "No";
      return 0;
    };
  for (int i = x1 + 1; i < x2; ++i)
    for (int j = y1 + 1; j < y2; ++j)
      if (a[i][j] != 4) {
        cout << "No";
        return 0;
      };
  if (x1 >= x2 - 1 || y1 >= y2 - 1) {
    cout << "No";
    return 0;
  };
  {
    cout << "Yes";
    return 0;
  };
}
