#include <bits/stdc++.h>
using namespace std;
using namespace std;
char sop[55][55];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> sop[i];
  int minCol = n, maxCol = -1, minRow = n, maxRow = -1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (sop[i][j] != '0') {
        minCol = min(minCol, j);
        maxCol = max(maxCol, j);
        minRow = min(minRow, i);
        maxRow = max(maxRow, i);
      }
    }
  bool fl = true;
  if (sop[minRow][minCol] == '1' && sop[minRow][maxCol] == '1' &&
      sop[maxRow][minCol] == '1' && sop[maxRow][maxCol] == '1') {
    for (int i = minRow + 1; i <= maxRow - 1; ++i) {
      if (!(sop[i][minCol] == '2' && sop[i][maxCol] == '2')) fl = false;
    }
    for (int j = minCol + 1; j <= maxCol - 1; ++j) {
      if (!(sop[minRow][j] == '2' && sop[maxRow][j] == '2')) fl = false;
    }
    for (int i = minRow + 1; i <= maxRow - 1; ++i)
      for (int j = minCol + 1; j <= maxCol - 1; ++j)
        if (sop[i][j] != '4') fl = false;
  } else
    fl = false;
  if (fl)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
