#include <bits/stdc++.h>
using namespace std;
int n, mat[55][55], ans[55][55];
int ok(int i, int j) { return (0 <= i && i < n && 0 <= j && j < n); }
int main() {
  int pi = -1, pj = -1, ui = -1, uj = -1;
  scanf("%d", &n);
  for (int(i) = (0); (i) < (n); (i)++)
    for (int(j) = (0); (j) < (n); (j)++) {
      char c;
      scanf(" %c", &c);
      mat[i][j] = c - '0';
      if (c == '1') {
        if (pi == -1) pi = i, pj = j;
        ui = i, uj = j;
      }
    }
  if (pi == -1) ui = n, uj = n;
  if (pi == ui && pj == uj) {
    if (mat[pi + 1][pj] == 2 && mat[pi][pj + 1] == 2)
      ui = n, uj = n;
    else if (mat[pi + 1][pj] == 2)
      pj = -1, ui = n;
    else if (mat[pi][pj + 1] == 2)
      pi = -1, uj = n;
    else
      pi = -1, pj = -1;
  }
  if (pi == ui) {
    if (pi && mat[pi - 1][pj] == 2)
      pi = -1;
    else
      ui = n;
  }
  if (pj == uj) {
    if (pj && mat[pi][pj - 1] == 2)
      pj = -1;
    else
      uj = n;
  }
  if (ui - pi == 1 || uj - pj == 1) {
    printf("No\n");
    return 0;
  }
  if (ok(pi, pj)) ans[pi][pj] = 1;
  if (ok(pi, uj)) ans[pi][uj] = 1;
  if (ok(ui, pj)) ans[ui][pj] = 1;
  if (ok(ui, uj)) ans[ui][uj] = 1;
  for (int(i) = (pj + 1); (i) < (uj); (i)++)
    if (ok(pi, i)) ans[pi][i] = 2;
  for (int(i) = (pj + 1); (i) < (uj); (i)++)
    if (ok(ui, i)) ans[ui][i] = 2;
  for (int(i) = (pi + 1); (i) < (ui); (i)++)
    if (ok(i, pj)) ans[i][pj] = 2;
  for (int(i) = (pi + 1); (i) < (ui); (i)++)
    if (ok(i, uj)) ans[i][uj] = 2;
  if (ui - pi == 2) {
    for (int(i) = (pj + 1); (i) < (uj); (i)++) ans[pi + 1][i] = 4;
  } else if (uj - pj == 2) {
    for (int(i) = (pi + 1); (i) < (ui); (i)++) ans[i][pj + 1] = 4;
  } else {
    pi++, pj++;
    for (int(i) = (pi); (i) < (ui); (i)++)
      for (int(j) = (pj); (j) < (uj); (j)++)
        if (ok(i, j)) ans[i][j] = 4;
  }
  for (int(i) = (0); (i) < (n); (i)++)
    for (int(j) = (0); (j) < (n); (j)++)
      if (ans[i][j] != mat[i][j]) {
        printf("No\n");
        return 0;
      }
  printf("Yes\n");
}
