defmodule Main do def toMin(time) do {h, m} = time (60 * h) + m end def toTime(min) do d = div(min, 1440) h = div(min, 60) - (24 * d) m = rem(min, 60) {h, m} end def main do inputs = IO.binread(:all) |> String.split [n, h, m, t] = Enum.map(inputs, &(String.to_integer(&1))) {hour, minute} = toMin({h, m}) + (t * (n - 1)) |> toTime IO.puts hour IO.puts minute end end