#include int main() { std::string str[64]; int N; int times = 0; std::vector v; std::string t; std::cin >> N; for(int i = 0; i < N; ++i) { std::cin >> t; t += "{"; str[i] = t; times += str[i].size()-1; } std::sort(str, str+N); for(int i = 0; i < times; ++i) { v.push_back(str[0][0]); for(int j = 1; j < str[0].size(); ++j) { str[0][j-1] = str[0][j]; } str[0][str[0].size()-1] = '\0'; str[0] = str[0].c_str(); if( str[0].size() == 1 ) { for(int j = 1; j < N; ++j) { str[j-1] = str[j]; } str[N-1] = "{"; } for(int j = 1; j < N; ++j) { if( str[j-1] > str[j] && str[j].size() != 1 ) { std::swap(str[j-1], str[j]); } else { break; } } /* std::cout << "----------" << i << std::endl; for(int i = 0; i < N; ++i) { std::cout << str[i] << std::endl; } */ } v.push_back('\0'); std::cout << &v[0] << std::endl; return 0; }