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
import sys

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 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[pivot_index] = values[high]
  left = low
  right = high
  while left < right:
    if compare(values[left], pivot) <= 0:
      left += 1
    else:
      right -= 1
      values[left], values[right] = values[right], values[left]
  values[high] = values[left]
  values[left] = pivot
  left -= 1
  while left > low and values[left] == pivot:
    left -= 1
  quicksort(values, compare, low, left)
  right += 1
  while right < high and values[right] == pivot:
    right += 1
  quicksort(values, compare, right, high)

if False:
  for i in range(500):
    data = [ random.randrange(1, 10) for i in range(3) ]
    sorted_data = data[:]
    quicksort(sorted_data, lambda a, b: a - b)
    if sorted_data != sorted(data):
      print(' '.join(map(str, sorted_data)) + ' !== ' +
          ' '.join(map(str, sorted(data))))
    #print(' '.join(map(str, data)))
  sys.exit()

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