#include <bits/stdc++.h>
char map[55][55];
int n;
inline bool check(int i, int j, char c) {
  if (i == 0 || j == 0 || i == n + 1 || j == n + 1) return true;
  if (map[i][j] == c) return true;
  return false;
}
bool solve() {
  int x, y, k, kk;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (map[i][j] == '4') {
        x = i, y = j;
        k = j, kk = i;
        while (map[i][k] == '4') k++;
        k--;
        while (map[kk][j] == '4') kk++;
        kk--;
        if (!check(i - 1, j - 1, '1') || !check(kk + 1, j - 1, '1') ||
            !check(kk + 1, k + 1, '1') || !check(i - 1, k + 1, '1'))
          return false;
        for (int e = i; e <= kk; e++)
          if (!check(e, j - 1, '2') || !check(e, k + 1, '2')) return false;
        for (int f = j; f <= k; f++)
          if (!check(i - 1, f, '2') || !check(kk + 1, f, '2')) return false;
        goto a;
      }
a:;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (((i <= x - 2) || (i >= kk + 2) || (j <= y - 2) || (j >= k + 2)) &&
          map[i][j] != '0')
        return false;
    }
  return true;
}
int main() {
  while (~scanf("%d", &n)) {
    memset(map, '0', sizeof(map));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) scanf(" %c", &map[i][j]);
    }
    if (solve())
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}
