defmodule Frac do defstruct nume: 0, deno: 1 def new(nume, deno) do if deno == 0, do: raise "ZeroDivision error" if deno < 0 do new(-nume, -deno) else %__MODULE__{nume: nume, deno: deno} end end def is_less_or_equal(a, b) do na = a.nume * b.deno nb = b.nume * a.deno na <= nb end end 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() a = li() m = ii() b = li() nume = hd(a) * (2..m//2 |> Enum.map(fn p -> Enum.at(b, p-1) end) |> Enum.product) deno = Enum.product(tl(a)) * (1..m//2 |> Enum.map(fn p -> Enum.at(b, p-1) end) |> Enum.product) # IO.inspect {:nume, nume, :deno, deno} g = Integer.gcd(nume, deno) nume = div(nume, g) deno = div(deno, g) IO.puts "#{nume} #{deno}" end end