#include using namespace std; int main() { int N; cin >> N; priority_queue, greater<>> que; for (int i = 0; i < N; i++) { string S; cin >> S; S += 'z' + 1; que.push(S); } string ans; while (!que.empty()) { string S = que.top(); que.pop(); ans += S[0]; if (S.length() >= 3) que.push(S.substr(1)); } cout << ans << endl; }