#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MAXN = 1e2 + 9;
const int MOD = (int)(1e9 + 7);
const int LOG2MAXN = 17;
const int INF = 1e9;
int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};
char ddir[] = {'R', 'U', 'L', 'D'};
int a[MAXN][MAXN];
void cry() {
  cout << "No";
  exit(0);
}
int A[5];
void solve() {
  int N;
  cin >> N;
  bool flag = false;
  int up = -1, down = MAXN, left = MAXN, right = -1;
  char c;
  cin.get(c);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin.get(c);
      a[i][j] = (int)c - '0';
      A[a[i][j]]++;
      if (a[i][j] == 4) {
        flag = true;
        up = max(i, up);
        down = min(i, down);
        left = min(left, j);
        right = max(right, j);
      }
    }
    cin.get(c);
  }
  if (!flag) cry();
  for (int i = down; i <= up; ++i) {
    for (int j = left; j <= right; ++j) {
      if (a[i][j] < 4) {
        cry();
      }
    }
  }
  if (down - 1 >= 0) {
    for (int i = left; i <= right; ++i) {
      if (a[down - 1][i] != 2) cry();
      --A[2];
    }
    if (left - 1 >= 0 && a[down - 1][left - 1] != 1) cry();
    if (right + 1 < N && a[down - 1][right + 1] != 1) cry();
    A[1] -= 2;
  }
  if (up + 1 < N) {
    for (int i = left; i <= right; ++i) {
      if (a[up + 1][i] != 2) cry();
      --A[2];
    }
    if (left - 1 >= 0 && a[up + 1][left - 1] != 1) cry();
    if (right + 1 > N && a[up + 1][right + 1] != 1) cry();
    A[1] -= 2;
  }
  if (left - 1 >= 0) {
    for (int i = down; i <= up; ++i) {
      if (a[i][left - 1] != 2) cry();
      --A[2];
    }
  }
  if (right + 1 < N) {
    for (int i = down; i <= up; ++i) {
      if (a[i][right + 1] != 2) cry();
      --A[2];
    }
  }
  if (A[1] > 0 || A[2] > 0 || A[3] != 0 ||
      A[4] != (up - down + 1) * (right - left + 1))
    cry();
  cout << "Yes";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
