#include <bits/stdc++.h>
using namespace std;
int a[50][50];
int main() {
  int n;
  cin >> n;
  bool dali1 = 1, dali2 = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char ch;
      cin >> ch;
      a[i][j] = ch - '0';
      if (a[i][j] == 3) dali1 = 0;
      if (a[i][j] == 4) dali2 = 1;
    }
  }
  if (!dali1 || !dali2) {
    cout << "No\n";
    return 0;
  }
  int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == 4) {
        if (x1 == -1) {
          x1 = i;
          y1 = j;
        }
        x2 = i;
        y2 = j;
      }
    }
  }
  for (int i = x1; i <= x2; i++) {
    for (int j = y1; j <= y2; j++) {
      if (a[i][j] != 4) {
        cout << "No\n";
        return 0;
      }
    }
  }
  if (x1 > 0) {
    if (y1 > 0 && a[x1 - 1][y1 - 1] != 1) {
      cout << "No\n";
      return 0;
    }
    for (int i = y1; i <= y2; i++) {
      if (a[x1 - 1][i] != 2) {
        cout << "No\n";
        return 0;
      }
    }
    if (y2 < n - 1 && a[x1 - 1][y2 + 1] != 1) {
      cout << "No\n";
      return 0;
    }
  }
  if (x2 < n - 1) {
    if (y1 > 0 && a[x2 + 1][y1 - 1] != 1) {
      cout << "No\n";
      return 0;
    }
    for (int i = y1; i <= y2; i++) {
      if (a[x2 + 1][i] != 2) {
        cout << "No\n";
        return 0;
      }
    }
    if (y2 < n - 1 && a[x2 + 1][y2 + 1] != 1) {
      cout << "No\n";
      return 0;
    }
  }
  if (y1 > 0) {
    for (int i = x1; i <= x2; i++) {
      if (a[i][y1 - 1] != 2) {
        cout << "No\n";
        return 0;
      }
    }
  }
  if (y2 < n - 1) {
    for (int i = x1; i <= x2; i++) {
      if (a[i][y2 + 1] != 2) {
        cout << "No\n";
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < x1 - 1; j++) {
      if (a[j][i] != 0) {
        cout << "No\n";
        return 0;
      }
    }
    for (int j = n - 1; j > x2 + 1; j--) {
      if (a[j][i] != 0) {
        cout << "No\n";
        return 0;
      }
    }
  }
  for (int i = x1 - 1; i <= x2 + 1; i++) {
    for (int j = 0; j < y1 - 1; j++) {
      if (a[i][j] != 0) {
        cout << "No\n";
        return 0;
      }
    }
    for (int j = n - 1; j > y2 + 1; j--) {
      if (a[i][j] != 0) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
