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;
template <class T>
inline void read(T &x) {
  x = 0;
  register char ch = getchar();
  int pd = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') pd = -pd;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= pd;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
bool sortbysec(const pair<long long, pair<long long, long long> > &a,
               const pair<long long, pair<long long, long long> > &b) {
  if (a.first != b.first) {
    return (a.first < b.first);
  } else {
    return a.second.first > b.second.first;
  }
}
void init() {}
string s, st;
long long x, y, k, t;
long long n, m, l, r, c, q, h, d, v, w, a, b;
long long mx = 1e9 + 1;
const long long nx = 1e4 + 1;
bool ar[26];
bool cmp1(long long n, pair<long long, pair<long long, long long> > const &p) {
  return (p.first > n);
}
bool cmp(string a, string b) { return a + b < b + a; }
string mg(string a, string b) {
  string xd = "";
  long long sp = a.size();
  for (auto x : a)
    if (x != '{') xd += x;
  for (auto x : b)
    if (x != '{') xd += x;
  for (long long(j) = (xd.size()); (j) < (2 * sp); ++(j)) xd += '{';
  return xd;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  cin >> n;
  vector<string> v(n);
  for (long long(i) = (0); (i) < (n); ++(i)) cin >> v[i];
  sort(v.begin(), v.end(), cmp);
  for (auto xd : v) cout << xd;
  return 0;
}