#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int n, a[55][55];
int main() {
  ios_base::sync_with_stdio(0);
  clock_t _ = clock();
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) scanf("%1d", a[i] + j);
    int sx, tx, sy, ty;
    sx = tx = sy = ty = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (a[i][j] == 1) {
          sx = i, sy = j;
          break;
        }
      }
      if (sx) break;
    }
    for (int i = n; i >= 1; --i) {
      for (int j = n; j >= 1; --j) {
        if (a[i][j] == 1) {
          tx = i, ty = j;
          break;
        }
      }
      if (tx) break;
    }
    bool ok = true;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (i < sx || i > tx || j < sy || j > ty) {
          if (a[i][j]) {
            ok = false;
          }
        }
    for (int i = sx; i <= tx; ++i)
      for (int j = sy; j <= ty; ++j) {
        if (i == sx && j == sy)
          ok &= a[i][j] == 1;
        else if (i == sx && j == ty)
          ok &= a[i][j] == 1;
        else if (i == tx && j == sy)
          ok &= a[i][j] == 1;
        else if (i == tx && j == ty)
          ok &= a[i][j] == 1;
        else if (i == sx)
          ok &= a[i][j] == 2;
        else if (i == tx)
          ok &= a[i][j] == 2;
        else if (j == sy)
          ok &= a[i][j] == 2;
        else if (j == ty)
          ok &= a[i][j] == 2;
        else
          ok &= a[i][j] == 4;
      }
    puts(ok ? "Yes" : "No");
  }
  return 0;
}
