#include <bits/stdc++.h>
using namespace std;
int n, cnt;
char c;
int a[105][105];
int dp[5][105][105];
void pre() {
  for (int type = 0; type <= 4; type++) {
    for (int i = 1; i <= n; i++) {
      int tmp = 0;
      for (int j = 1; j <= n; j++) {
        if (a[i][j] == type) tmp++;
        dp[type][i][j] = dp[type][i - 1][j] + tmp;
      }
    }
  }
}
int get(int type, int x1, int y1, int x2, int y2) {
  return dp[type][x2][y2] - dp[type][x1 - 1][y2] - dp[type][x2][y1 - 1] +
         dp[type][x1 - 1][y1 - 1];
}
bool check(int x1, int y1, int x2, int y2) {
  if (get(4, x1, y1, x2, y2) != (x2 - x1 + 1) * (y2 - y1 + 1)) return 0;
  if (y1 != 1) {
    if (get(2, x1, y1 - 1, x2, y1 - 1) != x2 - x1 + 1) return 0;
  }
  if (y2 != n) {
    if (get(2, x1, y2 + 1, x2, y2 + 1) != x2 - x1 + 1) return 0;
  }
  if (x1 != 1) {
    if (get(2, x1 - 1, y1, x1 - 1, y2) != y2 - y1 + 1) return 0;
  }
  if (x2 != n) {
    if (get(2, x2 + 1, y1, x2 + 1, y2) != y2 - y1 + 1) return 0;
  }
  if (x1 > 1 && y1 > 1 && a[x1 - 1][y1 - 1] != 1) return 0;
  if (x1 > 1 && y2 < n && a[x1 - 1][y2 + 1] != 1) return 0;
  if (x2 < n && y1 > 1 && a[x2 + 1][y1 - 1] != 1) return 0;
  if (x2 < n && y2 < n && a[x2 + 1][y2 + 1] != 1) return 0;
  if ((x2 - x1 + 3) * (y2 - y1 + 3) == cnt) return 1;
  return 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> c, a[i][j] = c - '0';
      if (a[i][j] != 0) cnt++;
    }
  pre();
  for (int x1 = 1; x1 <= n; x1++) {
    for (int y1 = 1; y1 <= n; y1++) {
      for (int x2 = x1; x2 <= n; x2++) {
        for (int y2 = y1; y2 <= n; y2++)
          if (check(x1, y1, x2, y2)) return cout << "Yes", 0;
      }
    }
  }
  cout << "No";
}
