output_description: Print the lexicographically smallest string that Iroha can produce.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N L
      S_1
      S_2
      :
      S_N
attempt: import sys
  
  lines = sys.stdin.readlines()
  
  strings = []
  max_len = 0
  for n, line in enumerate(lines):
      if n == 0:
          N, L = [int(_) for _ in line.strip().split(" ")]
          continue
      max_len = max([max_len, len(line.strip())])
      strings.append([ord(_) - 97 for _ in line.strip()])
  
  
  def append(source, target):
      global max_len
      # print('begin:', end='')
      # print(source, target)
      min_idx = -1
      check_idx = [_ for _ in range(max_len)]
      new_check_idx = []
      for digit in range(max_len):
          s_head_min = 26
          for n, s in enumerate(source):
              if not n in check_idx:
                  continue
              # print('digit:{}, check_idx:{}'.format(digit, check_idx))
              if s_head_min > s[digit]:
                  s_head_min = s[digit]
                  min_idx = n
              elif s_head_min == s[digit]:
                  new_check_idx.append(min_idx)
                  new_check_idx.append(n)
          if not len(new_check_idx):
              # print('Break!')
              # print(new_check_idx)
              break
          # print('new_check!')
          check_idx = new_check_idx
          new_check_idx = []
  
      target += "".join([chr(_ + 97) for _ in source[min_idx]])
      source.remove(source[min_idx])
      # print('end:', end='')
      # print(source, target)
      if not len(source):
          return target
      else:
          return append(source, target)
  
  
  print(append(strings, ""))
  
problem_description: 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.
samples: [{"input": "3 3\n    dxx\n    axx\n    cxx", "output": "axxcxxdxx\n    \n\nThe following order should be used: `axx`, `cxx`, `dxx`."}]