#include <bits/stdc++.h>
using namespace std;
struct Pt {
  long long int x, y;
};
int main() {
  ios::sync_with_stdio(false);
  long long int N;
  cin >> N;
  vector<string> arr(N), brr(N);
  for (long long int y = (0); y < (N); ++y) {
    cin >> arr[y];
    brr[y] = arr[y];
  }
  Pt st, en;
  st.x = -1;
  for (long long int y = (0); y < (N); ++y)
    for (long long int x = (0); x < (N); ++x) {
      if (arr[y][x] == '4') {
        if (st.x == -1) {
          st.x = x;
          st.y = y;
        }
        en.x = x;
        en.y = y;
      }
    }
  {
    for (long long int y = (0); y < (N); ++y)
      for (long long int x = (0); x < (N); ++x) brr[y][x] = '0';
    for (long long int y = (st.y); y < (en.y + 1); ++y)
      for (long long int x = (st.x); x < (en.x + 1); ++x) {
        brr[y][x] = '4';
      }
    for (long long int yy = (0); yy < (N); ++yy)
      for (long long int xx = (0); xx < (N); ++xx) {
        if (brr[yy][xx] == '0') {
          for (long long int i = (-1); i < (2); ++i)
            for (long long int j = (-1); j < (2); ++j) {
              int x = xx + i;
              int y = yy + j;
              if (x >= 0 && y >= 0 && x < N && y < N) {
                if (brr[y][x] == '4') brr[yy][xx] = '1';
              }
            }
        }
      }
    for (long long int yy = (0); yy < (N); ++yy)
      for (long long int xx = (0); xx < (N); ++xx) {
        if (brr[yy][xx] == '1') {
          for (long long int i = (-1); i < (2); ++i)
            for (long long int j = (-1); j < (2); ++j) {
              if (i * i + j * j == 1) {
                int x = xx + i;
                int y = yy + j;
                if (x >= 0 && y >= 0 && x < N && y < N) {
                  if (brr[y][x] == '4') brr[yy][xx] = '2';
                }
              }
            }
        }
      }
  }
  bool flag = true;
  for (long long int y = (0); y < (N); ++y) {
    for (long long int x = (0); x < (N); ++x) {
      if (arr[y][x] != brr[y][x]) flag = false;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}
