#include #include #include #include #include #include #include using namespace std; const char CHAR = 'z' + 1; int main() { int n; string input; cin >> n; priority_queue, greater > que; for (int i = 0; i < n; i++) { cin >> input; input.append(string(50, CHAR)); que.push(input); } string ans; string str; while(!que.empty()) { str = que.top(); que.pop(); ans += str[0]; str = str.substr(1); if (str[0] != CHAR) { que.push(str); } } cout << ans << endl; return 0; }