#include <bits/stdc++.h>
char A[50][50];
int main() {
  int n;
  std::cin >> n;
  int fr_i = n + 1;
  int to_i = -1;
  int fr_j = n + 1;
  int to_j = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      std::cin >> A[i][j];
      if (A[i][j] == '4') {
        fr_i = std::min(fr_i, i);
        to_i = std::max(to_i, i);
        fr_j = std::min(fr_j, j);
        to_j = std::max(to_j, j);
      }
    }
  }
  bool test = ((fr_i <= to_i) && (fr_j <= to_j));
  for (int i = 0; i < n && test; ++i) {
    for (int j = 0; j < n && test; ++j) {
      if (i == fr_i - 1 || i == to_i + 1) {
        if (j == fr_j - 1 || j == to_j + 1) {
          test = (A[i][j] == '1');
        } else if (fr_j <= j && j <= to_j) {
          test = (A[i][j] == '2');
        } else {
          test = (A[i][j] == '0');
        }
      } else if (fr_i <= i && i <= to_i) {
        if (j == fr_j - 1 || j == to_j + 1) {
          test = (A[i][j] == '2');
        } else if (fr_j <= j && j <= to_j) {
          test = (A[i][j] == '4');
        } else {
          test = (A[i][j] == '0');
        }
      } else {
        test = (A[i][j] == '0');
      }
    }
  }
  std::cout << (test ? "Yes" : "No") << std::endl;
  return 0;
}
