defmodule Main do def main do 1..(IO.read(:line) |> String.trim() |> String.to_integer()) |> Enum.map(fn _ -> IO.read(:line) |> String.trim() |> String.split() end) |> solve |> IO.puts() end def solve(s) do solve_rec(s, 0, 0) end def solve_rec([], c, w) do "#{c} #{w}" end def solve_rec([[t, s] | u], c, w) do v = s |> String.length() a = [v, (12 * (t |> String.to_integer())) |> div(1000)] |> Enum.min() solve_rec(u, c + a, w + v - a) end end