package main import ( "strconv" "strings" "fmt" ) func main() { var N int fmt.Scanf("%d", &N) var S = make([]string, N) for i := 0; i < N; i++ { fmt.Scanf("%s", &S[i]) S[i]+="{" } ans := "" for { minIndex := 0 current := "" for i := 0; i < N; i++ { if len(S[i]) == 0 { continue } if current == "" || current > S[i] { current = S[i] minIndex = i } } if len(S[minIndex]) == 0 { break } if S[minIndex][0] != '{' { ans+=string(S[minIndex][0]) } S[minIndex] = S[minIndex][1:] } fmt.Println(ans) } func mapToString(arr []int) []string { ret := make([]string, len(arr)) for i := 0; i < len(arr); i++ { ret[i] = strconv.Itoa(arr[i]) } return ret } func PrintI(args ...int) { fmt.Println(strings.Join(mapToString(args), " ")) }