defmodule Main do 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) def yn(b), do: IO.puts(if b, do: "Yes", else: "No") def main do n = ii() freq = Enum.frequencies(factorize(n)) for {k, v} <- freq, reduce: {1, 1} do {a, b} -> {d, m} = divmod(v, 2) a2 = if d == 0, do: 1, else: k ** d b2 = if m == 0, do: 1, else: k {a * a2, b * b2} end |> then(fn {a, b} -> IO.puts "#{a} #{b}" end) end def divmod(a, b), do: {div(a, b), rem(a, b)} def factorize(n) do factorize(n, 2) end defp factorize(n, p) do cond do n == 1 -> [] p * p > n -> [n] rem(n, p) == 0 -> [p | factorize(div(n, p), p)] true -> factorize(n, p+1) end end end