#include <bits/stdc++.h>
using namespace std;
int N, arr[55][55] = {0}, hitung = 0, satu = 0, dua = 0, tiga = 0, empat = 0;
char S[55][55], d;
int main() {
  scanf("%d%c", &N, &d);
  for (int i = 0; i < N; i++) gets(S[i]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) {
      if (S[i][j] != '0') arr[i][j] = 1, hitung++;
      if (S[i][j] == '1') satu++;
      if (S[i][j] == '2') dua++;
      if (S[i][j] == '3') tiga++;
      if (S[i][j] == '4') empat++;
      if (i > 0) arr[i][j] += arr[i - 1][j];
      if (j > 0) arr[i][j] += arr[i][j - 1];
      if (i > 0 && j > 0) arr[i][j] -= arr[i - 1][j - 1];
    }
  bool ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int p = i + 2; p < N; p++)
        for (int q = j + 2; q < N; q++) {
          int subRect = arr[p][q];
          if (i > 0) subRect -= arr[i - 1][q];
          if (j > 0) subRect -= arr[p][j - 1];
          if (i > 0 && j > 0) subRect += arr[i - 1][j - 1];
          if (subRect == hitung && (p - i + 1) * (q - j + 1) == hitung) ans = 1;
        }
  if (ans && 4 * empat >= satu && 4 * empat >= dua && tiga == 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}
