#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const char yes[] = "Yes";
const char no[] = "No";
char a[111][111];
int n;
void init(void) {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; i = i + 1) scanf("%s", a[i] + 1);
}
bool check(int x, int y, int val) {
  if (x < 1 || x > n || y < 1 || y > n) return (true);
  return (a[x][y] == val + '0');
}
bool process(void) {
  bool haveFour = false;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (a[i][j] == '4') haveFour = true;
  if (!haveFour) return (false);
  int up = n + 1;
  int down = 0;
  int ___left = n + 1;
  int ___right = 0;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (a[i][j] == '4') {
        minimize(up, i);
        maximize(down, i);
        minimize(___left, j);
        maximize(___right, j);
      }
  if (up > down || ___left > ___right) return (false);
  for (int i = (up), _b = (down); i <= _b; i = i + 1)
    for (int j = (___left), _b = (___right); j <= _b; j = j + 1)
      if (a[i][j] != '4') return (false);
  for (int i = (up), _b = (down); i <= _b; i = i + 1)
    if (!check(i, ___left - 1, 2)) return (false);
  for (int i = (up), _b = (down); i <= _b; i = i + 1)
    if (!check(i, ___right + 1, 2)) return (false);
  for (int i = (___left), _b = (___right); i <= _b; i = i + 1)
    if (!check(up - 1, i, 2)) return (false);
  for (int i = (___left), _b = (___right); i <= _b; i = i + 1)
    if (!check(down + 1, i, 2)) return (false);
  for (int i = 0, _n = (2); i < _n; i = i + 1)
    for (int j = 0, _n = (2); j < _n; j = j + 1) {
      int x = i ? up - 1 : down + 1;
      int y = j ? ___left - 1 : ___right + 1;
      if (!check(x, y, 1)) return (false);
    }
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1) {
      if (up - 1 <= i && i <= down + 1 && ___left - 1 <= j && j <= ___right + 1)
        continue;
      if (a[i][j] != '0') return (false);
    }
  return (true);
}
int main(void) {
  init();
  printf("%s\n", process() ? yes : no);
  return 0;
}
