#include <bits/stdc++.h>
using namespace std;
int n, s[51][51];
const int fx[] = {1, 1, -1, -1};
const int fy[] = {-1, 1, -1, 1};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%1d", &s[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (s[i][j] == 0) continue;
      int sum = 0;
      for (int k = 0; k < 4; k++)
        if (s[i + fx[k]][j + fy[k]]) sum++;
      if (s[i][j] != sum) return puts("No"), 0;
    }
  puts("Yes");
}
