#include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int n; cin >> n; vector s(n); for(int i=0; i> s[i]; s[i].resize(50, '{'); } string ans = ""; priority_queue, greater> pq(s.begin(), s.end()); while(pq.size()){ string tmp = pq.top(); pq.pop(); ans += tmp[0]; if(tmp.size() > 1 && tmp[1] != '{'){ tmp = tmp.substr(1,string::npos) + "{"; pq.push(tmp); } } cout << ans << endl; return 0; }