import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!size_t; auto si = iota(n).map!(_ => readln.chomp).array; auto hi = si.heapify!((a, b) { if (a.length == 1 && a[0] == b[0]) return true; else if (b.length == 1 && a[0] == b[0]) return false; else if (a > b) return true; else return false; }); auto s = ""; while (!hi.empty) { auto a = hi.front; s ~= a[0]; if (a.length == 1) hi.removeFront; else hi.replaceFront(a[1..$]); } writeln(s); }