def rpn(eq)
  # Reverse Polish Notation
  stack = []
  infix = [] # << infix notation
  eq.each{|i|
    case i
    when "+"
      b = stack.pop
      return nil if stack.size == 0
      stack[-1] += b

      n2 = infix.pop
      n1 = infix.pop
      infix << "(#{n1}+#{n2})"
    when "-"
      b = stack.pop
      return nil if stack.size == 0
      stack[-1] -= b

      n2 = infix.pop
      n1 = infix.pop
      infix << "(#{n1}-#{n2})"
    when "*"
      b = stack.pop
      return nil if stack.size == 0
      stack[-1] *= b

      n2 = infix.pop
      n1 = infix.pop
      infix << "(#{n1}*#{n2})"
    else
      stack << i
      infix << i
    end
  }
  return [stack[0], infix[0]] if stack.size == 1
  return nil
end

ope = ["+", "-", "*"]
opes = ope.repeated_combination(2).to_a
while input = gets
  input.chomp!
  break if input == "0 0 0 0"
  found = false
  lists = input.split.map(&:to_i).permutation.to_a.uniq
  lists.each{|list|
    eq = list[0,2]
    opes.each{|o|
      (list[2,2] + o[0,2]).permutation.to_a.uniq.each{|arr|
        ope.each{|p|
          ans = rpn(eq + arr + [p])
          if ans && ans[0] == 10
            found = ans[1]
            break
          end
        }
        break if found
      }
      break if found
    }
    break if found
  }
  if found
    puts found
  else
    puts 0
  end
end