func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<string> v;     string a;     while (n--) {       cin >> a;       v.push_back(a);     }     int cot = 0;     bool p = 1;     int ans = 1000000;     string c;     for (int j = 0; j < v.size(); j++) {       c = v[j];       cot = 0;       for (int i = 0; i < v.size(); i++) {         if (c == v[i] || i == j)           continue;         else {           int ncot = 0;           string b = v[i];           while (c != b) {             ncot++;             char d = b[0];             b.erase(b.begin());             b.push_back(d);             if (ncot > b.length()) {               p = 0;               break;             }           }           if (p == 0)             break;           else             cot += ncot;         }       }       if (p == 0) break;       if (cot < ans) {         ans = cot;       }     }     if (p)       cout << ans << endl;     else       cout << -1 << endl;   }   