Format = ["((( a . b ) . c ) . d )", "(( a . b ) . ( c . d ))", "(( a . ( b . c )) . d )", "( a . (( b . c ) . d ))", "( a . ( b . ( c . d )))"]
Operator = ["*", "+", "-"]
def rec(expression)
  return [expression] if !expression.include?(".")
  result = Array.new
  Operator.each do |operator|
    result += rec(expression.sub(/\./, operator))
  end
  result
end
while (a, b, c, d = gets.chomp.split.sort).find{|v| v != "0"} do
  answer = ""
  [a, b, c, d].permutation(4) do |list|
    Format.each do |expression|
      list.each do |n|
        expression = expression.sub(/[a-d]/, n)
      end
      rec(expression).each do |e|
        answer = e if eval(e) == 10
      end
    end
  end
  puts answer != "" ? answer : "0"
end