#include <bits/stdc++.h>
using namespace std;
const int M = 55;
bool isin[M][M];
int cnt[M][M], a[M][M];
int dx[4] = {1, 1, 0, 0};
int dy[4] = {0, 1, 0, 1};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
      if (a[i][j] == 4)
        for (int k = 0; k < 4; k++) isin[i + dx[k]][j + dy[k]] = 1;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 4; k++) cnt[i][j] += isin[i + dx[k]][j + dy[k]];
      if (cnt[i][j] != a[i][j]) {
        cout << "No\n";
        return 0;
      }
    }
  cout << "Yes\n";
  return 0;
}
