#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& a) {
  a = 0;
  char c;
  bool f = 0;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  do a = a * 10 + c - '0';
  while (isdigit(c = getchar()));
  if (f) a = -a;
}
const int INF = 0x7fffffff;
const long double eps = 1e-8;
const long long MOD = 1e9 + 7;
const int MAXN = 80;
char A[MAXN][MAXN];
int cnt[255];
int N, x0 = INF, jkhgsgkjh = INF, x1 = -1, gjerilgg = -1;
void result(string s) {
  cout << s << endl;
  exit(0);
}
int main(int argc, char* argv[]) {
  read(N);
  for (int i = 1; i <= N; ++i) scanf("%s", A[i] + 1);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j) ++cnt[A[i][j]];
  if (cnt['3']) result("No");
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= N; ++j)
      if (A[i][j] == '4') {
        ((x0) = min(x0, i));
        ((jkhgsgkjh) = min(jkhgsgkjh, j));
        ((x1) = max(x1, i));
        ((gjerilgg) = max(gjerilgg, j));
      }
  if ((x1 - x0 + 1) * (gjerilgg - jkhgsgkjh + 1) != cnt['4']) result("No");
  if (x0 != 1)
    for (int j = jkhgsgkjh; j <= gjerilgg; ++j)
      if (A[x0 - 1][j] != '2')
        result("No");
      else
        --cnt['2'];
  if (x1 != N)
    for (int j = jkhgsgkjh; j <= gjerilgg; ++j)
      if (A[x1 + 1][j] != '2')
        result("No");
      else
        --cnt['2'];
  if (jkhgsgkjh != 1)
    for (int i = x0; i <= x1; ++i)
      if (A[i][jkhgsgkjh - 1] != '2')
        result("No");
      else
        --cnt['2'];
  if (gjerilgg != N)
    for (int i = x0; i <= x1; ++i)
      if (A[i][gjerilgg + 1] != '2')
        result("No");
      else
        --cnt['2'];
  if (cnt['2']) result("No");
  if (x0 != 1 && jkhgsgkjh != 1)
    if (A[x0 - 1][jkhgsgkjh - 1] != '1')
      result("No");
    else
      --cnt['1'];
  if (x0 != 1 && gjerilgg != N)
    if (A[x0 - 1][gjerilgg + 1] != '1')
      result("No");
    else
      --cnt['1'];
  if (x1 != N && jkhgsgkjh != 1)
    if (A[x1 + 1][jkhgsgkjh - 1] != '1')
      result("No");
    else
      --cnt['1'];
  if (x1 != N && gjerilgg != N)
    if (A[x1 + 1][gjerilgg + 1] != '1')
      result("No");
    else
      --cnt['1'];
  if (cnt['1']) result("No");
  result("Yes");
  return 0;
}
