#include #include #include template using MinHeap = std::priority_queue, std::greater>; void solve() { MinHeap heap; int n; std::cin >> n; while (n--) { std::string s; std::cin >> s; s.push_back('~'); heap.push(s); } std::string t; while (!heap.empty()) { auto s = std::move(heap.top()); heap.pop(); if (s.front() == '~') continue; t.push_back(s.front()); s.erase(s.begin()); heap.push(s); } std::cout << t << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }