#include <bits/stdc++.h>
using namespace std;
int n;
char s[101][101];
int cur[101][101];
void fill(int x, int y) {
  for (int i = x; i <= x + 1; i++)
    for (int j = y; j <= y + 1; j++) {
      if (i < 0 || i >= n || j < 0 || j >= n) continue;
      cur[i][j]++;
    }
}
bool c(int x1, int y1, int x2, int y2) {
  memset(cur, 0, sizeof cur);
  for (int i = x1; i < x2; i++)
    for (int j = y1; j < y2; j++) fill(i, j);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] != cur[i][j] + '0') return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int x_mi = -1, y_mi = -1, x_ma = -1, y_ma = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (s[i][j] == '0') continue;
      if (x_mi == -1) x_mi = i;
      if (y_mi == -1) y_mi = j;
      x_ma = max(x_ma, i);
      y_ma = max(y_ma, j);
    }
  bool chk = false;
  for (int x1 = x_mi - 1; x1 <= x_mi && !chk; x1++)
    for (int y1 = y_mi - 1; y1 <= y_mi && !chk; y1++)
      for (int x2 = x_ma - 1; x2 <= x_ma && !chk; x2++)
        for (int y2 = y_ma - 1; y2 <= y_ma && !chk; y2++)
          chk = c(x1, y1, x2, y2);
  puts(chk ? "Yes" : "No");
  return 0;
}
