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;
typedef struct node {
  char str[55];
} node;
node ma[50050];
int n;
bool comp(node a, node b) {
  if (a.str[0] != b.str[0]) {
    return a.str[0] < b.str[0];
  } else {
    int la = strlen(a.str), lb = strlen(b.str);
    int i, j, l;
    l = min(la, lb);
    for (i = 0; i < l; i++) {
      if (a.str[i] != b.str[i]) return a.str[i] < b.str[i];
    }
    char a1[110], b1[110];
    for (i = 0; i < la; i++) a1[i] = a.str[i];
    for (i = la; i < la + lb; i++) a1[i] = b.str[i - la];
    a1[la + lb] = '\0';
    for (i = 0; i < lb; i++) b1[i] = b.str[i];
    for (i = lb; i < la + lb; i++) b1[i] = a.str[i - lb];
    b1[la + lb] = '\0';
    int tmp = strcmp(a1, b1);
    if (tmp == 0)
      return 0;
    else if (tmp > 0)
      return 0;
    else
      return 1;
  }
}
int main() {
  int i, j;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) scanf("%s", ma[i].str);
    sort(ma, ma + n, comp);
    for (i = 0; i < n; i++) {
      int tmp = strlen(ma[i].str);
      for (j = 0; j < tmp; j++) {
        printf("%c", ma[i].str[j]);
      }
    }
    putchar('\n');
  }
  return 0;
}