#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char c[55][55];
int s[55][55];
inline int ins(int x1, int y1, int x2, int y2, int first, int second) {
  return x1 <= first && first <= x2 && y1 <= second && second <= y2;
}
int main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> (c[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1, cnt = 0; j <= n; ++j)
      cnt += c[i][j] != '0', s[i][j] = cnt + s[i - 1][j];
  auto Sum = [&](int first, int second, int z, int t) {
    return s[z][t] - s[z][second - 1] - s[first - 1][t] +
           s[first - 1][second - 1];
  };
  for (int x1 = 1; x1 <= n; ++x1)
    for (int x2 = x1 + 1; x2 <= n; ++x2)
      for (int y1 = 1; y1 <= n; ++y1)
        for (int y2 = y1 + 1; y2 <= n; ++y2)
          if (Sum(x1, y1, x2, y2) == s[n][n] &&
              Sum(x1, y1, x2, y2) == (x2 - x1 + 1) * (y2 - y1 + 1)) {
            for (int i = 1; i <= n; ++i)
              for (int j = 1; j <= n; ++j)
                if (ins(x1, y1, x2, y2, i, j)) {
                  if (c[i][j] - '0' != ins(x1, y1, x2, y2, i - 1, j - 1) +
                                           ins(x1, y1, x2, y2, i + 1, j + 1) +
                                           ins(x1, y1, x2, y2, i - 1, j + 1) +
                                           ins(x1, y1, x2, y2, i + 1, j - 1)) {
                    cout << ("No") << '\n';
                    exit(0);
                  };
                }
            {
              cout << ("Yes") << '\n';
              exit(0);
            };
          }
  puts("No");
  return 0;
}
