#include <bits/stdc++.h>
int n, c[55][55], l = 100, r = -1, t = 100, b = -1, ans[55][55];
char s[55];
bool ok() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (ans[i][j] != c[i][j]) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < n; j++) {
      c[i][j] = s[j] - '0';
      if (c[i][j] == 1) {
        l = std::min(l, j);
        r = std::max(r, j);
        t = std::min(t, i);
        b = std::max(b, i);
      }
    }
  }
  if (l == 100 || r == -1 || t == 100 || b == -1) {
    printf("No\n");
    return 0;
  }
  ans[t][l]++;
  for (int j = l + 1; j < r; j++) ans[t][j] += 2;
  ans[t][r]++;
  for (int i = t + 1; i < b; i++) {
    ans[i][l] += 2;
    for (int j = l + 1; j < r; j++) ans[i][j] += 4;
    ans[i][r] += 2;
  }
  ans[b][l]++;
  for (int j = l + 1; j < r; j++) ans[b][j] += 2;
  ans[b][r]++;
  printf(ok() && l != r && t != b ? "Yes\n" : "No\n");
}
