#include <bits/stdc++.h>   using namespace std;   string str;   vector<int> graph[26], rgraph[26];   bool visited[26];   bool present[26];   void dfs(int i) {     visited[i] = true;     if (graph[i].size() >= 1 && !visited[graph[i][0]]) dfs(graph[i][0]);     str.insert(str.begin(), (char)( a  + i));   }   void rdfs(int i) {     visited[i] = true;     if (rgraph[i].size() >= 1 && !visited[rgraph[i][0]]) {       str.insert(str.begin(), (char)( a  + rgraph[i][0]));       rdfs(rgraph[i][0]);     }   }   int main() {     int n;     cin >> n;     string s[n];     for (int i = 0; i < n; i++) cin >> s[i];     memset(present, false, sizeof(present));     for (int i = 0; i < n; i++) {       for (int j = 0; j < s[i].length() - 1; j++) {         graph[s[i][j] -  a ].push_back(s[i][j + 1] -  a );         rgraph[s[i][j + 1] -  a ].push_back(s[i][j] -  a );         present[s[i][j] -  a ] = true;       }       present[s[i][s[i].length() - 1] -  a ] = true;     }     memset(visited, 0, sizeof(visited));     for (int i = 0; i < 26; i++) {       if (present[i] && !visited[i]) {         dfs(i);         rdfs(i);       }     }     cout << str;   }   