#include <bits/stdc++.h>
using namespace std;
char a[102][102];
int n;
void solve(int x, int y, int xx, int yy) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i >= x && i <= xx && j >= y && j <= yy) {
        if (a[i][j] != '4') return;
      } else if ((i - 1 >= x && i - 1 <= xx && j >= y && j <= yy) ||
                 (i + 1 >= x && i + 1 <= xx && j >= y && j <= yy) ||
                 (i >= x && i <= xx && j - 1 >= y && j - 1 <= yy) ||
                 (i >= x && i <= xx && j + 1 >= y && j + 1 <= yy)) {
        if (a[i][j] != '2') return;
      } else if ((i - 1 >= x && i - 1 <= xx && j - 1 >= y && j - 1 <= yy) ||
                 (i - 1 >= x && i - 1 <= xx && j + 1 >= y && j + 1 <= yy) ||
                 (i + 1 >= x && i + 1 <= xx && j - 1 >= y && j - 1 <= yy) ||
                 (i + 1 >= x && i + 1 <= xx && j + 1 >= y && j + 1 <= yy)) {
        if (a[i][j] != '1') return;
      } else if (a[i][j] != '0')
        return;
    }
  cout << "Yes\n";
  exit(0);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i][j] == '4') {
        for (int ii = n; ii > 0; ii--)
          for (int jj = n; jj > 0; jj--)
            if (a[ii][jj] == '4') {
              solve(i, j, ii, jj);
              cout << "No\n";
              return 0;
            }
      }
  cout << "No\n";
}
