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

Solution:
import random

def compare_fragments(a, b):
  if a == b:
    return 0
  n, m = len(a), len(b)
  if a.count(a[0]) == n and b.count(a[0]) == m:
    if n < m:
      return -1
    return 1
  i, j = 0, 0
  while a[i] == b[j]:
    i += 1
    if i == n:
      i = 0
    j += 1
    if j == m:
      j = 0
      if i == 0:
        return 0
  if a[i] < b[j]:
    return -1
  return 1

def compare_ints(a, b):
  return a - b

def quicksort(values, compare, low=0, high=None):
  if high == None:
    high = len(values) - 1
  if low >= high:
    return
  pivot_index = random.randrange(low, high + 1)
  pivot = values[pivot_index]
  values[low], values[pivot_index] = values[pivot_index], values[low]
  left = low + 1
  right = high + 1
  while left < right:
    if compare(values[left], pivot) <= 0:
      left += 1
    else:
      right -= 1
      values[left], values[right] = values[right], values[left]
  pivot_index = left - 1
  values[low], values[pivot_index] = values[pivot_index], pivot
  quicksort(values, compare, low, pivot_index - 1)
  quicksort(values, compare, pivot_index + 1, high)

n = int(raw_input())
fragments = [ raw_input().strip() for i in range(n) ]
#quicksort(fragments, compare_fragments)
fragments.sort(cmp=compare_fragments)
print(''.join(fragments))