#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, i, j, x1, x2, y1, y2;     cin >> n;     vector<string> a(n);     for (i = 0; i < n; i++) cin >> a[i];     x1 = 0;     y1 = 0;     while (a[x1][y1] ==  0  && (x1 <= n - 1 || y1 < n - 1))       if (y1 == n - 1) {         y1 = 0;         x1++;       } else         y1++;     x2 = n - 1;     y2 = n - 1;     while (a[x2][y2] ==  0  && (x2 > 0 || y2 > 0))       if (y2 == 0) {         y2 = n - 1;         x2--;       } else         y2--;     bool f = true;     if (x1 > x2 || y1 > y2) f = false;     if (a[x1][y1] !=  1 ) f = false;     if (a[x1][y2] !=  1 ) f = false;     if (a[x2][y1] !=  1 ) f = false;     if (a[x2][y2] !=  1 ) f = false;     for (i = y1 + 1; i < y2; i++)       if (a[x1][i] !=  2  || a[x2][i] !=  2 ) f = false;     for (i = x1 + 1; i < x2; i++)       if (a[i][y1] !=  2  || a[i][y2] !=  2 ) f = false;     for (i = x1 + 1; i < x2; i++)       for (j = y1 + 1; j < y2; j++)         if (a[i][j] !=  4 ) f = false;     for (i = 0; i < x1; i++)       for (j = 0; j < n; j++)         if (a[i][j] !=  0 ) f = false;     for (i = x2 + 1; i < n; i++)       for (j = 0; j < n; j++)         if (a[i][j] !=  0 ) f = false;     for (i = 0; i < n; i++)       for (j = 0; j < y1; j++)         if (a[i][j] !=  0 ) f = false;     for (i = 0; i < n; i++)       for (j = y2 + 1; j < n; j++)         if (a[i][j] !=  0 ) f = false;     if (f)       cout <<  Yes  << endl;     else       cout <<  No  << endl;   }   