#include <bits/stdc++.h>
using namespace std;
int n;
char a[51][51];
int x[2], y[2];
bool check() {
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++)
      if (a[x[i]][y[i]] != '1') return false;
  for (int i = x[0] + 1; i <= x[1] - 1; i++)
    if (a[i][y[0]] != '2') return false;
  for (int i = x[0] + 1; i <= x[1] - 1; i++)
    if (a[i][y[1]] != '2') return false;
  for (int i = y[0] + 1; i <= y[1] - 1; i++)
    if (a[x[0]][i] != '2') return false;
  for (int i = y[0] + 1; i <= y[1] - 1; i++)
    if (a[x[1]][i] != '2') return false;
  for (int i = x[0] + 1; i <= x[1] - 1; i++)
    for (int j = y[0] + 1; j <= y[1] - 1; j++)
      if (a[i][j] != '4') return false;
  return true;
}
int main() {
  int k, t;
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) scanf("%s", a[i]);
  x[0] = y[0] = 101, x[1] = y[1] = -1;
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= n - 1; j++)
      if (a[i][j] != '0')
        x[0] = min(x[0], i), x[1] = max(x[1], i), y[0] = min(y[0], j),
        y[1] = max(y[1], j);
  if (check())
    puts("Yes");
  else
    puts("No");
  return 0;
}
