#include <bits/stdc++.h>
using namespace std;
bool go_line_left(int start, int stop, int y, vector<vector<int> >& grid) {
  bool res = true;
  for (int i = start + 1; i != stop; i++)
    if (grid[i][y] != 2) res = false;
  return res;
}
bool go_line_down(int start, int stop, int x, vector<vector<int> >& grid) {
  bool res = true;
  for (int i = start + 1; i != stop; i++)
    if (grid[x][i] != 2) res = false;
  return res;
}
bool get_coords(int& x1, int& x2, int& y1, int& y2,
                vector<pair<int, int> >& corners) {
  if (corners.size() != 4) return false;
  if (corners[0].first != corners[1].first) return false;
  if (corners[0].second != corners[2].second) return false;
  if (corners[1].second != corners[3].second) return false;
  if (corners[2].first != corners[3].first) return false;
  x1 = corners[0].first;
  y1 = corners[0].second;
  x2 = corners[3].first;
  y2 = corners[3].second;
  return true;
}
bool check_inside(int x1, int x2, int y1, int y2, vector<vector<int> >& grid) {
  for (int i = x1 + 1; i != x2; i++)
    for (int j = y1 + 1; j != y2; j++)
      if (grid[i][j] != 4) return false;
  return true;
}
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  vector<vector<int> > grid;
  grid.resize(n);
  vector<pair<int, int> > corners;
  bool alright = true;
  for (int i = 0; i < n; ++i) {
    grid[i].resize(n);
    for (int j = 0; j < n; ++j) {
      grid[i][j] = getchar() - '0';
      if (grid[i][j] == 1) corners.push_back(make_pair(i, j));
    }
    getchar();
  }
  int x1, x2, y1, y2;
  alright = alright && get_coords(x1, x2, y1, y2, corners);
  alright = alright && go_line_left(x1, x2, y1, grid);
  alright = alright && go_line_left(x1, x2, y2, grid);
  alright = alright && go_line_down(y1, y2, x1, grid);
  alright = alright && go_line_down(y1, y2, x2, grid);
  alright = alright && check_inside(x1, x2, y1, y2, grid);
  if (alright)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
