func_code_string: #include <bits/stdc++.h>   using namespace std;   string func(pair<int, int> a, pair<int, int> b) {     return to_string(a.first) +     + to_string(a.second) +     +            to_string(b.first) +     + to_string(b.second);   }   int nSmallFactor(int n, vector<int>& primes) {     for (int prime : primes) {       if (n % prime == 0) {         return prime;       }     }     return -1;   }   void DFS(vector<int>& ve, vector<int>& visited, int n, int start) {     int ans = 0;     for (int i = start + start; i <= n; i += start) {       if (visited[i] == -1) {         DFS(ve, visited, n, i);       }       if (ve[i] > ve[start]) {         ans = max(ans, visited[i]);       }     }     visited[start] = ans + 1;   }   long long sum(long long a) {     if (a % 2 == 0) {       return (a / 2) * (a + 1);     }     return ((a + 1) / 2) * a;   }   long long sum(long long a, long long b) { return sum(b) - sum(a - 1); }   vector<int> getPrimes(int n) {     vector<int> primes;     primes.push_back(2);     bool isPrime;     for (int i = 3; i * i <= n; i++) {       isPrime = true;       for (int p = 0; p < primes.size() && primes[p] * primes[p] <= i; p++) {         if (i % primes[p] == 0) {           isPrime = false;           break;         }       }       if (isPrime) {         primes.push_back(i);       }     }     return primes;   }   int findMaxPrime(vector<int> primes, int n, int k) {     int ans = INT_MAX;     bool findAns = true;     int ncpy = n;     for (int i = 0; primes[i] <= k && primes[i] * primes[i] <= n; i++) {       if (findAns && n % primes[i] == 0) {         ans = primes[i];       }       while (n % primes[i] == 0) {         n /= primes[i];       }     }     if (n <= k) {       ans = min(ans, ncpy / n);     }     ans = min(ans, ncpy);     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int ttt = 1;     cin >> ttt;     string s;     int temp;     int n, k;     int p, q, a, b, c, d;     bool ans;     vector<int> primes = getPrimes(1000000005);     int row, col;     while (ttt--) {       cin >> n;       bool a[n][n];       string s;       for (int i = (int)0; i < (int)n; i++) {         cin >> s;         for (int j = (int)0; j < (int)n; j++) {           if (s[j] ==  1 ) {             a[i][j] = true;           } else {             a[i][j] = false;           }         }       }       bool possible = true;       for (int i = 1; possible && i < n; i++) {         row = n - i - 1;         p = row;         for (p; p >= 0; p--) {           if (a[row][p]) {             if (!a[row][p + 1] && !a[row + 1][p]) {               possible = false;               break;             }           }         }         col = row;         p = col;         for (p; p >= 0; p--) {           if (a[p][col]) {             if (!a[p][col + 1] && !a[p + 1][col]) {               possible = false;               break;             }           }         }       }       if (possible) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }     return 0;   }   