#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 10;
int n;
char S[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);
  int x1 = n + 1, x2 = -1;
  int y1 = n + 1, y2 = -1;
  int cnt4 = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      if (S[i][j] != '4') continue;
      x1 = min(x1, i);
      y1 = min(y1, j);
      x2 = max(x2, i);
      y2 = max(y2, j);
      cnt4++;
    }
  if ((x2 - x1 + 1) * (y2 - y1 + 1) != cnt4) {
    puts("No");
    return 0;
  };
  for (int i = 1; i <= x1 - 2; ++i)
    for (int j = 1; j <= n; ++j)
      if (S[i][j] != '0') {
        puts("No");
        return 0;
      };
  for (int i = x2 + 2; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (S[i][j] != '0') {
        puts("No");
        return 0;
      };
  for (int j = 1; j <= y1 - 2; ++j)
    for (int i = 1; i <= n; ++i)
      if (S[i][j] != '0') {
        puts("No");
        return 0;
      };
  for (int j = y2 + 2; j <= n; ++j)
    for (int i = 1; i <= n; ++i)
      if (S[i][j] != '0') {
        puts("No");
        return 0;
      };
  if (x1 > 1 && y1 > 1 && S[x1 - 1][y1 - 1] != '1') {
    puts("No");
    return 0;
  };
  if (x1 > 1 && y2 < n && S[x1 - 1][y2 + 1] != '1') {
    puts("No");
    return 0;
  };
  if (x2 < n && y1 > 1 && S[x2 + 1][y1 - 1] != '1') {
    puts("No");
    return 0;
  };
  if (x2 < n && y2 < n && S[x2 + 1][y2 + 1] != '1') {
    puts("No");
    return 0;
  };
  if (x1 > 1)
    for (int i = y1; i <= y2; ++i)
      if (S[x1 - 1][i] != '2') {
        puts("No");
        return 0;
      };
  if (x2 < n)
    for (int i = y1; i <= y2; ++i)
      if (S[x2 + 1][i] != '2') {
        puts("No");
        return 0;
      };
  if (y1 > 1)
    for (int i = x1; i <= x2; ++i)
      if (S[i][y1 - 1] != '2') {
        puts("No");
        return 0;
      };
  if (y2 < n)
    for (int i = x1; i <= x2; ++i)
      if (S[i][y2 + 1] != '2') {
        puts("No");
        return 0;
      };
  puts("Yes");
  return 0;
}
