Problem: You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.

Given the list of strings, output the lexicographically smallest concatenation.

Input

The first line contains integer n — the number of strings (1 ≤ n ≤ 5·104).

Each of the next n lines contains one string ai (1 ≤ |ai| ≤ 50) consisting of only lowercase English letters. The sum of string lengths will not exceed 5·104.

Output

Print the only string a — the lexicographically smallest string concatenation.

Examples

Input

4
abba
abacaba
bcd
er


Output

abacabaabbabcder


Input

5
x
xx
xxa
xxaa
xxaaa


Output

xxaaaxxaaxxaxxx


Input

3
c
cb
cba


Output

cbacbc

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void bad(string mes = "impossible") {
  cout << mes;
  exit(0);
}
template <typename T>
string bin(T x, int st = 2) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % st);
    x /= st;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}
template <typename T>
T dcm(string& second) {
  T x = 0;
  for (int i = 0; i < second.size(); i++) {
    x = (x * 2) + (second[i] == '1');
  }
  return x;
}
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + int(c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
T binpow(T n, T second) {
  if (second <= 0) return 1LL;
  if (second % 2 == 0) {
    T b = binpow(n, second / 2);
    return (1LL * b * b);
  } else {
    return (1LL * binpow(n, second - 1) * n);
  }
}
const int inf = 2e9;
const double eps = 1e-9;
const int maxn = 1e5 + 10, base = 1e9 + 7;
const int sigm = 26;
const long long llinf = 1e18;
int cnt[100];
bool cmp(string a, string b) {
  string c;
  string g;
  c = a + b;
  g = b + a;
  if (c < g) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> ans(n);
  for (int i = 0; i < n; i++) cin >> ans[i];
  sort(ans.begin(), ans.end(), cmp);
  for (int i = 0; i < n; i++) cout << ans[i];
  return 0;
}