#include <bits/stdc++.h>
using namespace std;
const int oo = 51;
int n, a[oo][oo], x, y;
string s;
bool mark;
bool check(int u, int d, int r, int l) {
  int b[oo][oo];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) b[i][j] = 0;
  for (int i = u; i <= d; i++)
    for (int j = l; j <= r; j++) b[i][j] = 4;
  for (int j = l; u && j <= r; j++) b[u - 1][j] = 2;
  for (int j = l; d < n - 1 && j <= r; j++) b[d + 1][j] = 2;
  for (int i = u; l && i <= d; i++) b[i][l - 1] = 2;
  for (int i = u; r < n - 1 && i <= d; i++) b[i][r + 1] = 2;
  if (l) {
    if (u) b[u - 1][l - 1] = 1;
    b[d + 1][l - 1] = 1;
  }
  if (u) b[u - 1][r + 1] = 1;
  b[d + 1][r + 1] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] != b[i][j]) return false;
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      a[i][j] = s[j] - '0';
      if (a[i][j] == 3) {
        cout << "No";
        return 0;
      } else if (a[i][j] == 4 && !mark)
        x = i, y = j, mark = true;
    }
  }
  for (int p = x; p < n; p++)
    for (int q = y; q < n - 1; q++)
      if (check(x, p, q, y)) {
        cout << "Yes";
        return 0;
      }
  cout << "No";
  return 0;
}
