#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++) #define rE(i,b) reE(i,0,b) #define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++) #define rT(i,b) reT(i,0,b) #define rep(i,a,b) reE(i,a,b); #define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--) #define fe(i,b) for (auto &(x):b); #define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i)) #define rti(i,b) for(auto (i)=(b).rbegin();(i)!=(b).rend();++(i)) #define LL long long #define all(b) (b).begin(),(b).end() #define input_init stringstream ss; string strtoken, token; istringstream is #define input_line getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit) #define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num #define dir(xx,yy,x,y,i) (xx)=(x)+dir[(i)],(yy)=(y)+dir[(i)+1] typedef pair P; int main(void){ int N; cin >> N; //priority_queue, greater

> que; vector > str(N); /* vector used(N, false); */ string s; for (int i = 0; i < N; i++){ cin >> s; for (auto& var : s){ str[i].push_back(var); } } s = ""; while(str[0].size()>0){ s += str[0].front(); str[0].pop_front(); } for (auto& var : str){ string t = ""; int i = 0; while (var.size()>0 || i < (int)s.size()){ if (var.size() == 0 || var.front() > s[i]) t += s[i++]; else { t += var.front(); var.pop_front(); } } s = t; } cout <