implementation

#include <cassert>
#include <functional>
#include <iostream>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
using namespace std;

bool is_suffix(string const & a, string const & b) {
if (a.length() > b.length()) return false;
return b.compare(b.length() - a.length(), a.length(), a) == 0;
}
void setshort(string & a, string const & b) {
if (a.empty() or b.length() < a.length() or (a.length() == b.length() and b < a)) {
a = b;
}
}

int main() {
while (true) {
// input
int n; cin >> n;
if (n == 0) break;
vector<string> word(n); repeat (i, n) cin >> word[i];
// solve
vector<string> dp(1 << n);
function<void (string const &, int)> go = [&](string const & s, int used) {
repeat (i, n) if (not (used & (1 << i))) {
if (s.find(word[i]) != string::npos) {
used |= 1 << i;
}
}
setshort(dp[used], s);
repeat (i, n) if (not (used & (1 << i))) {
repeat_from (sep, 1, word[i].length()) {
if (is_suffix(word[i].substr(0, sep), s)) {
go(s + word[i].substr(sep), used | (1 << i));
}
}
}
};
repeat (i, n) {
go(word[i], 1 << i);
}
repeat (a, 1 << n) if (not dp[a].empty()) {
repeat (b, 1 << n) {
if ((b | a) == a) { // b \subseteq a
setshort(dp[b], dp[a]);
}
}
}
repeat_from (a, 1, 1 << n) {
assert (not dp[a].empty());
repeat (b, 1 << n) if (not dp[b].empty()) {
if (not (a & b)) {
setshort(dp[a | b], dp[a] + dp[b]);
setshort(dp[a | b], dp[b] + dp[a]);
}
}
}
// output
cout << dp[(1 << n) - 1] << endl;
}
return 0;
}