import algorithm, sequtils, strutils let read* = iterator: string = while true: (for s in stdin.readLine.split: yield s) template input*(T: static[typedesc]): untyped = when T is int: read().parseInt elif T is float: read().parseFloat elif T is string: read() elif T is char: read()[0] let N = input(int) let books: seq[tuple[S, id: string]] = newSeqWith(N, (S: input(string), id: input(string))) .sortedByIt((it.S, it.id)) echo books.mapIt(it.S & " " & it.id).join("\n")