#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n + 2][n + 2];
  bool mark[n + 2][n + 2];
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      a[i][j] = '5';
      mark[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  vector<pair<int, int> > g;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == '4') {
        g.push_back(make_pair(i, j));
        mark[i][j] = 1;
        mark[i - 1][j] = 1;
        mark[i - 1][j - 1] = 1;
        mark[i - 1][j + 1] = 1;
        mark[i][j - 1] = 1;
        mark[i][j + 1] = 1;
        mark[i + 1][j] = 1;
        mark[i + 1][j - 1] = 1;
        mark[i + 1][j + 1] = 1;
      }
    }
  }
  int x = g.size();
  if (x == 0) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (a[i][j] != '0') {
          cout << "No";
          return 0;
        }
      }
    }
    cout << "Yes";
    return 0;
  }
  int x1 = g[0].first;
  int y1 = g[0].second;
  int x2 = g[x - 1].first;
  int y2 = g[x - 1].second;
  for (int i = y1; i <= y2; i++) {
    if (a[x1 - 1][i] == '2' || a[x1 - 1][i] == '5') {
    } else {
      cout << "No";
      return 0;
    }
  }
  for (int i = y1; i <= y2; i++) {
    if (a[x2 + 1][i] == '2' || a[x2 + 1][i] == '5') {
    } else {
      cout << "No";
      return 0;
    }
  }
  for (int i = x1; i <= x2; i++) {
    if (a[i][y1 - 1] == '2' || a[i][y1 - 1] == '5') {
    } else {
      cout << "No";
      return 0;
    }
  }
  for (int i = x1; i <= x2; i++) {
    if (a[i][y2 + 1] == '2' || a[i][y2 + 1] == '5') {
    } else {
      cout << "No";
      return 0;
    }
  }
  if ((a[x1 - 1][y1 - 1] == '1' || a[x1 - 1][y1 - 1] == '5') &&
      (a[x2 + 1][y1 - 1] == '1' || a[x2 + 1][y1 - 1] == '5') &&
      (a[x1 - 1][y2 + 1] == '1' || a[x1 - 1][y2 + 1] == '5') &&
      (a[x2 + 1][y2 + 1] == '1' || a[x2 + 1][y2 + 1] == '5')) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (mark[i][j] == 0 && a[i][j] != '0') {
          cout << "No";
          return 0;
        }
      }
    }
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
