n = input() n_list = n.split() n_intlist = [int(s) for s in n_list] #print(n_intlist) lists = [] for i in range(n_intlist[0]): i = input() i_list = i.split() i_intlist = [int(s) for s in i_list] lists.extend(i_intlist) #print(lists) lists.sort() #print(lists) lists_str = [str(n) for n in lists] #print(lists_str) lists_count = len(lists_str) i = 0 count = 0 while i < lists_count: print(lists_str[i],end="") i += 1 count += 1 if count % 5 == 0: print("")