#include <bits/stdc++.h>
using namespace std;
char a[51][51];
int main() {
  memset(a, '0', sizeof(a));
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int x = a[i][j] - '0';
      if (x != 0) {
        if (a[i - 1][j - 1] != '0') x--;
        if (a[i - 1][j + 1] != '0') x--;
        if (a[i + 1][j - 1] != '0') x--;
        if (a[i + 1][j + 1] != '0') x--;
        if (x != 0) return cout << "No", 0;
      }
    }
  cout << "Yes";
  return 0;
}
