#include using namespace std; const int MAX_N = 1e6 + 10; vector vs; char ans[MAX_N]; int at = 0; vector ap['z' - 'a' + 1]; int bsearch(int c, int st) { vector &v = ap[c]; size_t i, step; for(step = 1; step < v.size(); step *= 2); for(i = 0; step; step /= 2) { if(i + step < v.size() && v[i + step] <= st) i += step; } i++; if(i >= v.size()) return -1; return v[i]; } bool included(const string &s) { int lo = 0; for(auto &i: s) { int next = bsearch(i, lo); if(next == -1) return 0; lo = next + 1; } return 1; } void append(const string &s) { for(const auto &i: s) { ap[(int)i].push_back(at); ans[at] = i; at++; } } int main() { string s; while(cin >> s) { vs.push_back(s); } sort(vs.begin(), vs.end(), [](const string &s, const string &t) { return s.length() > t.length(); }); for(auto &i: vs) { if(included(i)) continue; else append(i); } cout << ans << "\n"; return 0; }