#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; string S[55]; int cur[55]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int all = 0; for (int i = 0; i < N; i++) { cin >> S[i]; all += S[i].size(); } string T; string last; for (int i = 0; i < 50; i++) last += "z"; while (1) { if (T.size() == all) break; vector > words; for (int i = 0; i < N; i++) { if (cur[i] == S[i].size()) continue; words.push_back(make_pair(S[i].substr(cur[i])+last, i)); } sort(words.begin(), words.end()); cur[words[0].second]++; T += words[0].first.substr(0, 1); } cout << T << endl; return 0; }