defmodule Main do def main do n = ii() xs = for _ <- 1..n, into: [] do [a, b] = input() |> String.split {a, b} end for {a, b} <- Enum.sort(xs, &cmp/2) do IO.puts "#{a} #{b}" end end def cmp({a, b}, {c, d}) do if a == c do b <= d else a <= c end end def input, do: IO.read(:line) |> String.trim def ii, do: input() |> String.to_integer def li, do: input() |> String.split |> Enum.map(&String.to_integer/1) end