local read = io.read
local byte = string.byte
local N, L = read("*n", "*n")
read("*l")
local S = {}
for i = 1, N do
	local str = read("*l")
	S[i] = {byte(str, 1, L)}
	setmetatable(S[i], {__call = function() return str end})
end

local function isDict(s1, s2)
	for i = 1, L do
		if s1[i] < s2[i] then
			return true
		elseif s1[i] > s2[i] then
			return false
		end
	end
	return false
end

table.sort(S, isDict)
local out = ""
for i = 1, N do
	out = out..S[i]()
end

print(out)
