#include <bits/stdc++.h>
using namespace std;
char s[55][55];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int x1, y1, x2, y2;
  int cnt = 0;
  int ff = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (s[i][j] == '1') {
        if (ff == 0) {
          x1 = i;
          y1 = j;
          ff = 1;
        } else {
          x2 = i;
          y2 = j;
        }
        cnt++;
      }
    }
  if (cnt == 4) {
    if (s[x1][y2] == '1' && s[x2][y1] == '1') {
      int flag = 1;
      for (int l = y1 + 1; l < y2 && flag; l++)
        if (s[x1][l] != '2') flag = 0;
      for (int l = y1 + 1; l < y2 && flag; l++)
        if (s[x2][l] != '2') flag = 0;
      for (int l = x1 + 1; l < x2 && flag; l++)
        if (s[l][y1] != '2') flag = 0;
      for (int l = x1 + 1; l < x2 && flag; l++)
        if (s[l][y2] != '2') flag = 0;
      for (int l = x1 + 1; l < x2 && flag; l++)
        for (int r = y1 + 1; r < y2 && flag; r++)
          if (s[l][r] != '4') flag = 0;
      for (int l = 0; l < n && (l < x2 || l > x2) && flag; l++)
        for (int r = 0; r < n && (r < y1 || r > y2) && flag; r++)
          if (s[l][r] != '0') flag = 0;
      if (flag)
        printf("Yes\n");
      else
        printf("No\n");
    }
  } else
    printf("No\n");
  return 0;
}
