#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int N = 55;
int n;
int use[N][N], a[N][N], b[N][N];
void dfs(int first, int second) {
  if (!(!use[first][second] && first > 0 && first <= n && second > 0 &&
        second <= n && a[first][second] == 4)) {
    return;
  }
  use[first][second] = true;
  dfs(first + 1, second);
  dfs(first - 1, second);
  dfs(first, second + 1);
  dfs(first, second - 1);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  int first = -1, second = -1;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= n; j++) {
      a[i][j] = (s[j - 1] - '0');
      if (a[i][j] == 4) {
        first = i;
        second = j;
      }
    }
  }
  dfs(first, second);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (use[i][j]) b[i][j] = a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (use[i + 1][j] || use[i - 1][j] || use[i][j - 1] || use[i][j + 1]) {
        b[i][j] = max(b[i][j], 2);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (use[i + 1][j + 1] || use[i - 1][j - 1] || use[i - 1][j + 1] ||
          use[i + 1][j - 1]) {
        b[i][j] = max(b[i][j], 1);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] != b[i][j]) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
