#include <bits/stdc++.h>
using namespace std;
int n, cnt = 0, mx_i = 0, mn_i = 55, mx_j = 0, mn_j = 55;
string s[55];
char s2[51][51];
bool vis[51][50], ans = true;
void dfs(int i, int j) {
  if (s[i][j] != '4') {
    s2[i][j] = '2';
    return;
  }
  cnt++;
  s2[i][j] = '4';
  mx_i = max(i, mx_i);
  mx_j = max(j, mx_j);
  mn_i = min(i, mn_i);
  mn_j = min(j, mn_j);
  vis[i][j] = true;
  if (i < n - 1 && !vis[i + 1][j]) dfs(i + 1, j);
  if (i && !vis[i - 1][j]) dfs(i - 1, j);
  if (j < n - 1 && !vis[i][j + 1]) dfs(i, j + 1);
  if (j && !vis[i][j - 1]) dfs(i, j - 1);
}
int main() {
  cin >> n;
  memset(s2, '0', sizeof s2);
  for (int i = 0; i < n; i++) cin >> s[i];
  int i1, j1;
  bool found = false;
  for (int i = 0; i < n && !found; i++) {
    for (int j = 0; j < n && !found; j++) {
      if (s[i][j] == '4') {
        found = true;
        i1 = i;
        j1 = j;
      }
    }
  }
  if (found) {
    dfs(i1, j1);
    if (((mx_i - mn_i + 1) * (mx_j - mn_j + 1)) != cnt) {
      ans = false;
    }
    s2[mn_i - 1][mn_j - 1] = s2[mn_i - 1][mx_j + 1] = s2[mx_i + 1][mn_j - 1] =
        s2[mx_i + 1][mx_j + 1] = '1';
    if (ans) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          if (s[i][j] != s2[i][j]) {
            ans = false;
          }
        }
      }
      if (ans) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
