#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int grid[50][50];
  char c;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> c;
      grid[i][j] = c - '0';
    }
  }
  vector<pair<int, int>> ones;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (grid[i][j] == 1) {
        ones.push_back(pair<int, int>(i, j));
      }
    }
  }
  if (ones.size() != 4) {
    cout << "No";
    return 0;
  }
  int xdif, ydif;
  if (ones[0].first != ones[1].first || ones[0].second != ones[2].second) {
    cout << "No";
    return 0;
  }
  ydif = ones[1].second - ones[0].second;
  xdif = ones[2].first - ones[0].first;
  if ((ones[3].first != ones[0].first + xdif) ||
      (ones[3].second != ones[0].second + ydif)) {
    cout << "No";
    return 0;
  }
  for (int i = ones[0].second + 1; i < ones[1].second; i++) {
    if (grid[ones[0].first][i] != 2) {
      cout << "No";
      return 0;
    }
  }
  for (int i = ones[0].first + 1; i < ones[2].first; i++) {
    if (grid[i][ones[0].second] != 2) {
      cout << "No";
      return 0;
    }
  }
  for (int i = ones[2].second + 1; i < ones[3].second; i++) {
    if (grid[ones[2].first][i] != 2) {
      cout << "No";
      return 0;
    }
  }
  for (int i = ones[1].first + 1; i < ones[3].first; i++) {
    if (grid[i][ones[1].second] != 2) {
      cout << "No";
      return 0;
    }
  }
  for (int i = ones[0].second + 1; i < ones[1].second; i++) {
    for (int j = ones[0].first + 1; j < ones[2].first; j++) {
      if (grid[j][i] != 4) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}
