#include <bits/stdc++.h>
using namespace std;
char h[70][70];
int ii[100000];
int jj[100000];
int main() {
  int n;
  cin >> n;
  int a1 = 0, a2 = 0, a4 = 0, kol = n * n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> h[i][j];
      if (h[i][j] == '0') {
        kol--;
      }
      if (h[i][j] == '1') {
        ii[a1] = i;
        jj[a1] = j;
        a1++;
      }
      if (h[i][j] == '2') {
        a2++;
      }
      if (h[i][j] == '4') {
        a4++;
      }
    }
  }
  if (a1 != 4) {
    cout << "No";
    return 0;
  }
  if (ii[0] != ii[1]) {
    cout << "No";
    return 0;
  }
  if (ii[2] != ii[3]) {
    cout << "No";
    return 0;
  }
  if (jj[0] != jj[2]) {
    cout << "No";
    return 0;
  }
  if (jj[1] != jj[3]) {
    cout << "No";
    return 0;
  }
  for (int i = ii[0] + 1; i < ii[2]; i++) {
    a1 += 2;
    if (h[i][jj[0]] != '2') {
      cout << "No";
      return 0;
    }
    if (h[i][jj[1]] != '2') {
      cout << "No";
      return 0;
    }
  }
  for (int j = jj[0] + 1; j < jj[1]; j++) {
    a1 += 2;
    if (h[ii[0]][j] != '2') {
      cout << "No";
      return 0;
    }
    if (h[ii[2]][j] != '2') {
      cout << "No";
      return 0;
    }
  }
  for (int i = ii[0] + 1; i < ii[2]; i++) {
    for (int j = jj[0] + 1; j < jj[1]; j++) {
      a1 += 1;
      if (h[i][j] != '4') {
        cout << "No";
        return 0;
      }
    }
  }
  if (a1 == kol)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
