#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int N; vector S; void solve(){ each(s, S)s += '~'; string ans; while(true){ int k = -1; rep(i, N) if(k==-1||S[i] < S[k]) k = i; if(S[k][0]=='~'){ break; } else{ ans += S[k][0]; S[k] = S[k].substr(1); } } cout << ans << endl; } int main(){ while(cin >> N){ S.resize(N); rep(i, N)cin >> S[i]; solve(); } }