#include <bits/stdc++.h>
using namespace std;
int nr[53][53];
int nrc[53][53];
int ans;
int main() {
  ios::sync_with_stdio(0);
  int n = 0;
  cin >> n;
  ans = 1;
  char str[n + 1];
  for (int i = 0; i < n + 2; i++) nr[0][i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;
    nr[i + 1][0] = 0;
    for (int j = 0; j < n; j++) nr[i + 1][j + 1] = str[j] - '0';
    nr[i + 1][n + 1] = 0;
  }
  for (int i = 0; i < n + 2; i++) nr[n + 1][i] = 0;
  for (int i = 0; i < n + 2; i++)
    for (int j = 0; j < n + 2; j++) nrc[i][j] = 0;
  int temp;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < n + 1; j++) {
      temp = 0;
      if (nr[i - 1][j] != 0) temp++;
      if (nr[i][j - 1] != 0) temp++;
      if (nr[i][j + 1] != 0) temp++;
      if (nr[i + 1][j] != 0) temp++;
      if (temp == 1 || temp == 0)
        nrc[i][j] = 0;
      else {
        if (temp == 2)
          nrc[i][j] = 1;
        else if (temp == 3)
          nrc[i][j] = 2;
        else
          nrc[i][j] = temp;
      }
    }
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < n + 2; j++) {
      if (nr[i][j] != nrc[i][j]) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
