#include <bits/stdc++.h>
using namespace std;
bool solve() {
  int n;
  cin >> n;
  vector<string> g(n);
  for (int i = 0; i < n; i++) cin >> g[i];
  int one = 0;
  for (int i = 0; i < n; i++) one += count(g[i].begin(), g[i].end(), '1');
  if (one != 4) return false;
  int y1 = INT_MAX;
  int x1 = INT_MAX;
  int y2 = INT_MIN;
  int x2 = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] == '1') {
        y1 = min(y1, i);
        x1 = min(x1, j);
        y2 = max(y2, i);
        x2 = max(x2, j);
      }
    }
  }
  if (g[y1][x1] != '1') return false;
  if (g[y2][x1] != '1') return false;
  if (g[y2][x2] != '1') return false;
  if (g[y1][x2] != '1') return false;
  static int cnt[55][55];
  for (int i = y1; i <= y2; i++) {
    for (int j = x1; j <= x2; j++) {
      cnt[i][j] += 2;
    }
  }
  for (int i = y1 + 1; i <= y2 - 1; i++) {
    for (int j = x1 + 1; j <= x2 - 1; j++) {
      cnt[i][j] += 2;
    }
  }
  for (int y : {y1, y2}) {
    for (int x : {x1, x2}) {
      cnt[y][x]--;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] - '0' != cnt[i][j]) return false;
    }
  }
  return true;
}
int main() { puts(solve() ? "Yes" : "No"); }
