#include <bits/stdc++.h>   using namespace std;   string gen[100];   string merge(string s1, string s2) {     int e = s1.size() - 1;     for (int i = 0; i < s2.size(); i++) {       if (s1[0] == s2[i]) {         int k = s2.size() - i;         if (k <= s1.size()) {           s1.erase(0, k);           return s2 + s1;         }         return s2;       }       if (s1[e] == s2[i]) {         if (e - i >= 0) {           s1.erase(e - i, i + 1);           return s1 + s2;         }         return s2;       }     }     return  0 ;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> gen[i];     }     bool f = true;     for (int k = 0; k < n; k++) {       f = true;       while (f && gen[k] !=   ) {         f = false;         for (int i = k + 1; i < n; i++) {           if (gen[i] !=   ) {             string s;             if (gen[i].length() < gen[k].length()) {               s = merge(gen[i], gen[k]);             } else {               s = merge(gen[k], gen[i]);             }             if (s !=  0 ) {               gen[k] = s;               gen[i] =   ;               f = true;               break;             }           }         }       }     }     string s3;     for (int i = 0; i < n; i++) {       s3 += gen[i];     }     cout << s3;     return 0;   }   