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;
const long long MOD = 1000000007;
const long long N = 200000;
bool is_vowel_up(char c) {
  return c == 'A' || c == 'E' || c == 'I' || c == 'U' || c == 'O' || c == 'Y';
}
bool is_vowel_low(char c) {
  return c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y';
}
long long Strtoll(string str) {
  stringstream second(str);
  long long x = 0;
  second >> x;
  return x;
}
string llostr(long long x) {
  stringstream second;
  second << x;
  string str = second.str();
  return str;
}
template <typename T>
T add(T a, T b) {
  return a + b >= MOD ? a + b - MOD : a + b;
}
template <typename T>
T sub(T a, T b) {
  return a - b < 0 ? a - b + MOD : a - b;
}
template <typename T>
T mul(T a, T b) {
  return (a * 1LL * b) % MOD;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int substr_cnt(string s, string p) {
  int i, ans = 0, len = p.size();
  for (int i = 0; i < s.size() - len + 1; i++) {
    if (p == s.substr(i, len)) ans++;
  }
  return ans;
}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int fx[] = {1, 1, 1, 0, -1, -1, -1, 0};
int fy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
void pallab() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
string vs[500000];
bool cmp(string a, string b) { return (a + b < b + a); }
int main() {
  pallab();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> vs[i];
  sort(vs, vs + n, cmp);
  for (string i : vs) cout << i;
  return 0;
}