#include using namespace std; int main() { int N; cin >> N; priority_queue, vector>, greater>> pque; for (size_t i = 0; i < N; i++) { string S; cin >> S; deque deq; for (size_t j = 0; j < S.size(); j++) { deq.push_back(S[j]); } pque.push(deq); } string ans = ""; while (pque.size()) { auto deq = pque.top(); pque.pop(); ans += deq.front(); deq.pop_front(); if (deq.size()) { pque.push(deq); } } cout << ans << endl; }