Problem:


Score : 200 points

Problem Statement

Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.

She will concatenate all of the strings in some order, to produce a long string.

Among all strings that she can produce in this way, find the lexicographically smallest one.

Here, a string s=s_1s_2s_3...s_n is lexicographically smaller than another string t=t_1t_2t_3...t_m if and only if one of the following holds:

There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.

s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Constraints

1 ≦ N, L ≦ 100

For each i, the length of S_i equals L.

For each i, S_i consists of lowercase letters.

Input

The input is given from Standard Input in the following format:

N L
S_1
S_2
:
S_N

Output

Print the lexicographically smallest string that Iroha can produce.

Sample Input 1

3 3
dxx
axx
cxx

Sample Output 1

axxcxxdxx

The following order should be used: axx, cxx, dxx.



Sample input:
3 3
dxx
axx
cxx


Sample output:
axxcxxdxx

Submission status: Runtime Error

Solution code:
n,l = map(int,input().split())
s = []
for i in range(n):
    s.append(input())
s.sort()
print(s[0]+s[1]+s[2])

Submission status: Runtime Error

Solution code:
3 3
dxx
axx
cxx

Submission status: Runtime Error

Solution code:
N,L=map(int,input().split())
S=[input() for i in range(N)]


Ts=""
T=[]
for j in range(L):
    t=j
    for i in range(N):
        if t==L: t=0
        Ts+=S[t]
        t+=1
    T.append(Ts)
    Ts=""

print(min(T))

Submission status: Runtime Error

Solution code:
N,L = [int(i) for i in input().split()]
S=[[i for i in input().strip()] for j in range(N)]
print(''.join(sorted(S)))

Submission status: Runtime Error

Solution code:
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

from math import factorial
H,W,A,B=map(int, input().split())
p=10**9+7
ans=0
X=[1]
Y=[1]
for i in range(H+W-2):
  fact=factorial(i+1)%p
  X+=[fact]
  Y+=[power_func( fact, p-2,p)]
for i in range(B,W):
  ans+=X[H-A-1+i]*X[A+W-2-i]*(Y[H-A-1]*Y[i]*Y[A-1]*Y[W-1-i])%p

print(ans)

Submission status: Runtime Error

Solution code:
L, N = map(int,input().split())
S = [input() for i in range(N)]

S.sort()


print("".join(S))

Submission status: Runtime Error

Solution code:
L, N = map(int,input().split())
S = [input() for i in range(N)]

B=sorted(S)

A=''.join(B)

print(str(A))

Submission status: Runtime Error

Solution code:
L, N = map(int,input().split())
S = [input() for i in range(N)]

S=sorted(S)

A=''.join(S)

print(str(A))

Submission status: Runtime Error

Solution code:
L, N = map(int,input().split())
S = [input() for i in range(N)]

S.sort()

A=''.join(S)

print(str(A))

Submission status: Runtime Error

Solution code:
L, N = map(int,input().split())
S = [input() for i in range(N)]

S.sort()

A=''.join(S)

print(A)

Submission status: Runtime Error

Solution code:
n, l = map(int, raw_input().split())

for i in xrange(n):
  a.append(raw_input())
a.sort()
print "".join(a)

Submission status: Runtime Error

Solution code:
n, l = map(int, raw_input().split())

for i in xrange(n):
  a.append(raw_input())
a.sort()
print " ".join(a)

Submission status: Runtime Error

Solution code:
import sys
L, N = map(int, raw_input().split())
input = []
for i in range(0, N):
 sentence = raw_input()
 input.append(sentence)
 
for x in sorted(input):
    sys.stdout.write(x)

Submission status: Runtime Error

Solution code:
#pythonだとsortでそのまま何文字でもソートしてくれる
n, l = map(int, input().split())
s = [input()  for _ in range(n)]]
print(''.join(sorted(s)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# problem B

N, L = map(int, input().split())
ls = []

for _ in N:
    input_data = input()
    ls.append(input_data)

ls.sort()
print(''.join(ls))

Submission status: Runtime Error

Solution code:
    N, L = map(int, input().split())
    data = []
    for _ in range(N):
        input_data = input()
        data.append(input_data)
    print(data)
    data.sort()
    print(''.join(data))

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
print("".join(sorted[input() for i in range(n)]))

Submission status: Runtime Error

Solution code:
N,L = map(int, input().split())
S = 26*[""] 
for i in range(N):
    S[i] = input()

S.sort()

str = ""

for s in S:
    str += s

print(str)

Submission status: Runtime Error

Solution code:
import heapq
N, L = map(int, raw_input().split())
hq = []
for _ in xrange(N:
    s = raw_input()
    heapq.heappush(hq, s)
ans = ''
while len(hq) > 0:
    ans += heapq.heappop(hq)
print ans

Submission status: Runtime Error

Solution code:
print("".join(sorted([input() for i in range(int(input().split[0]))])))

Submission status: Runtime Error

Solution code:
import sys

def main(lines):
    print(''.join(sorted(lines.split())))

next(sys.stdin)
for line in sys.stdin:
    lines += line
main(lines)

Submission status: Runtime Error

Solution code:
N = int(input().split()[0])
words = [input() for i in range(N)]
print("".join(words.sort()))

Submission status: Runtime Error

Solution code:
N = input().split()[0]
words = [input() for i in range(N)]
print("".join(words.sort()))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000)
n, l = map(int, raw_input().split())
s = [raw_input() for _ in xrange(n)]
gtable = [[] for _ in xrange(26)]
result = []

def searchPrint(e, n):
    table = [[] for _ in xrange(26)]
    for i in e:
        table[ord(s[i][n]) - 97].append(i)
        
    for el in table:
        if len(el) == 0:
            continue
        if len(el) == 1:
            result.append(s[el[0]])
            continue
        if n == l-1:
            for i in el:
                result.append(s[i])
            continue
        searchPrint(el, n+1)
    
for i in xrange(n):
    gtable[ord(s[i][0]) - 97].append(i)
    
for e in gtable:
    if len(e) == 0:
        continue
    searchPrint(e, 1)
    
print "".join(result)

Submission status: Runtime Error

Solution code:
n, l = map(int, raw_input().split())
s = [raw_input() for _ in xrange(n)]
gtable = [[] for _ in xrange(26)]
result = []

def searchPrint(e, n):
    table = [[] for _ in xrange(26)]
    for i in e:
        table[ord(s[i][n]) - 97].append(i)
        
    for el in table:
        if len(el) == 0:
            continue
        if len(el) == 1:
            result.append(s[el[0]])
            continue
        if n == l-1:
            for i in el:
                result.append(s[i])
            continue
        searchPrint(el, n+1)
    
for i in xrange(n):
    gtable[ord(s[i][0]) - 97].append(i)
    
for e in gtable:
    if len(e) == 0:
        continue
    searchPrint(e, 1)
    
print "".join(result)

Submission status: Runtime Error

Solution code:
N, L = raw_input().split()
l = []
for _ in range(N):
    l.append(raw_input().strip())
print "".join(sorted(l))

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())

s = []
for i in range(n):
  t = input()
  s.append(t)

s.sort()

print(s.join(''))