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 PYTHON3):

Solution:
def mergesort(s):
    if len(s) == 1:
        return s
    s1 = mergesort(s[:len(s) // 2])
    s2 = mergesort(s[len(s) // 2:])
    return merge(s1, s2)


def merge(s1, s2):
    f = []
    ind1 = 0
    ind2 = 0
    while ind1 != len(s1) and ind2 != len(s2):
        if str(s1[ind1]) + str(s2[ind2]) > str(s2[ind2]) + str(s1[ind1]):
            f.append(s2[ind2])
            ind2 += 1
        else:
            f.append(s1[ind1])
            ind1 += 1
    if ind1 != len(s1):
        f.extend(s1[ind1:])
    else:
        f.extend(s2[ind2:])
    return f


n = int(input())
s = []
for i in range(n):
    s.append(input())
print(''.join(mergesort(s)))