#include <bits/stdc++.h>   using namespace std;   int main() {     char prev[26], next[26];     for (int i = 0; i < 26; i++) prev[i] = next[i] = -1;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       if (prev[s[0] -  a ] == -1) prev[s[0] -  a ] = 0;       if (next[s[(int)s.size() - 1] -  a ] == -1)         next[s[(int)s.size() - 1] -  a ] = 0;       for (int j = 1; j < (int)s.size(); j++) {         prev[s[j] -  a ] = s[j - 1];         next[s[j - 1] -  a ] = s[j];       }     }     for (int i = 0; i < 26; i++) {       if (prev[i] == 0) {         char cur =  a  + i;         while (cur) {           printf( %c , cur);           cur = next[cur -  a ];         }       }     }     return 0;   }   