#include #include #include #include using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; int sp[50]; string s[50]; bool cmp(int x, int y) { int i = sp[x], j = sp[y]; while (true) { if (i >= s[x].size()) return false; if (j >= s[y].size()) return true; if (s[x][i] < s[y][j]) return true; else if (s[x][i] > s[y][j]) return false; i++; j++; } } int main(void) { int i, n; cin >> n; rep (i,n) cin >> s[i]; rep (i,n) sp[i] = 0; while (true) { char mn; int imn = -1; rep (i,n) if (sp[i] < s[i].size()) { if (imn == -1 || cmp(i,imn)) { mn = s[i][sp[i]]; imn = i; } } if (imn == -1) break; cout << mn; sp[imn]++; } cout << endl; return 0; }