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;
struct In {
  In operator>>(int &p) const {
    int re = 0;
    register int n = 0, sign = 1, a = getchar();
    while (a < '0' || a > '9') {
      if (a == '-') {
        sign = -1;
        a = getchar();
        break;
      }
      a = getchar();
    }
    while (a >= '0' && a <= '9') {
      n = (n << 1) + (n << 3) + a - '0';
      a = getchar();
    }
    p = n * sign;
    return *this;
  }
  In operator>>(signed long long &x) const {
    scanf("%I64d", &x);
    return *this;
  }
  In operator>>(double &x) const {
    scanf("%lf", &x);
    return *this;
  }
  In operator>>(char &x) const {
    do {
      x = getchar();
    } while (x == ' ' || x == '\n');
    return *this;
  }
  In operator>>(char *x) const {
    scanf("%s", x);
    return *this;
  }
  In operator>>(string &s) const {
    char buf[1000005];
    operator>>(buf);
    s = buf;
    return *this;
  }
} I;
struct Out {
  Out operator<<(const int x) const {
    printf("%d", x);
    return *this;
  }
  Out operator<<(const signed long long x) const {
    printf("%I64d", x);
    return *this;
  }
  Out operator<<(const double x) const {
    printf("%lf", x);
    return *this;
  }
  Out operator<<(const char x) const {
    putchar(x);
    return *this;
  }
  Out operator<<(const char *x) const {
    printf("%s", x);
    return *this;
  }
  Out operator<<(const string x) const { return operator<<(x.c_str()); }
} O;
const int N = 50005;
string s[N], ans;
int n;
bool cmp(string a, string b) { return (a + b) < (b + a); }
int main() {
  I >> n;
  for (int i = 0; i < n; i++) I >> s[i];
  sort(s, s + n, cmp);
  for (int i = 0; i < n; i++) ans += s[i];
  O << ans;
}