#include <bits/stdc++.h>
using namespace std;
int n;
char mp[60][60];
int main() {
  int y, x, yy, xx;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%s", mp[i] + 1);
  y = x = -1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (mp[i][j] == '4') {
        y = i;
        x = j;
        break;
      }
    }
    if (y != -1) break;
  }
  if (y == -1) {
    puts("No");
    return 0;
  }
  for (yy = y + 1; yy <= n && mp[yy][x] == '4'; ++yy)
    ;
  --yy;
  for (xx = x + 1; xx <= n && mp[y][xx] == '4'; ++xx)
    ;
  --xx;
  for (int i = y; i <= yy; ++i) {
    for (int j = x; j <= xx; ++j) {
      if (mp[i][j] != '4') {
        puts("No");
        return 0;
      }
      mp[i][j] = '0';
    }
  }
  if (y - 1 > 0 && x - 1 > 0 && mp[y - 1][x - 1] != '1') {
    puts("No");
    return 0;
  }
  if (y - 1 > 0 && xx + 1 <= n && mp[y - 1][xx + 1] != '1') {
    puts("No");
    return 0;
  }
  if (yy + 1 <= n && x - 1 > 0 && mp[yy + 1][x - 1] != '1') {
    puts("No");
    return 0;
  }
  if (yy + 1 <= n && xx + 1 <= n && mp[yy + 1][xx + 1] != '1') {
    puts("No");
    return 0;
  }
  mp[y - 1][x - 1] = '0';
  mp[y - 1][xx + 1] = '0';
  mp[yy + 1][x - 1] = '0';
  mp[yy + 1][xx + 1] = '0';
  for (int i = x; i <= xx; ++i) {
    if (y - 1 > 0) {
      if (mp[y - 1][i] != '2') {
        puts("No");
        return 0;
      }
      mp[y - 1][i] = '0';
    }
    if (yy + 1 <= n) {
      if (mp[yy + 1][i] != '2') {
        puts("No");
        return 0;
      }
      mp[yy + 1][i] = '0';
    }
  }
  for (int i = y; i <= yy; ++i) {
    if (x - 1 > 0) {
      if (mp[i][x - 1] != '2') {
        puts("No");
        return 0;
      }
      mp[i][x - 1] = '0';
    }
    if (xx + 1 <= n) {
      if (mp[i][xx + 1] != '2') {
        puts("No");
        return 0;
      }
      mp[i][xx + 1] = '0';
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (mp[i][j] != '0') {
        puts("No");
        return 0;
      }
  puts("Yes");
  return 0;
}
