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 t = ii() for _ <- 1..t do [a, b, c] = li() solve(a, b, c) |> IO.puts end end def solve(a, b, c) do m = Enum.max([a, b, c]) cond do m == a -> f(a, c, b) m == b -> f(b, max(a, c), min(a, c)) m == c -> f(c, a, b) end end def f(a, b, c) do cond do a <= b -> x = b - a + 1 res = f(a, b-x, c) if res == -1 do -1 else x + res end b <= c -> x = c - b + 1 if c-x <= 0 do -1 else x end true -> 0 end end def is_kadomatu(a, b, c) do if a == b or b == c or c == a do false else [_, x, _] = Enum.sort([a, b, c]) b != x end end end