#include <bits/stdc++.h>
using namespace std;
string s[100];
int n;
bool valid(int i, int j, int cnt) {
  int sum = 0;
  if (i > 0 && j > 0 && s[i - 1][j - 1] != '0' && s[i - 1][j] != '0' &&
      s[i][j - 1] != '0')
    sum++;
  if (i > 0 && j < n && s[i - 1][j + 1] != '0' && s[i - 1][j] != '0' &&
      s[i][j + 1] != '0')
    sum++;
  if (i < n && j > 0 && s[i + 1][j - 1] != '0' && s[i + 1][j] != '0' &&
      s[i][j - 1] != '0')
    sum++;
  if (i < n && j < n && s[i + 1][j + 1] != '0' && s[i + 1][j] != '0' &&
      s[i][j + 1] != '0')
    sum++;
  return sum == cnt;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s[i][j] != '0') {
        if (!valid(i, j, s[i][j] - '0')) {
          cout << "No\n";
          return 0;
        }
      }
    }
  }
  int cornerIdx = -1, cornerIdxY = -1;
  int width = 0, Height = 0;
  for (int i = 0; i < n; i++) {
    cornerIdx = -1;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == '1') {
        cornerIdx = j;
        cornerIdxY = i;
        while (j < n && s[i][j] != '0') {
          width++;
          j++;
        }
        break;
      }
    }
    if (cornerIdx != -1) {
      while (i < n && s[i][cornerIdx] != '0') {
        Height++;
        i++;
      }
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i >= cornerIdxY && i < cornerIdxY + Height && j >= cornerIdx &&
          j < cornerIdx + width)
        continue;
      if (s[i][j] != '0') {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
