def calc_rev_polish(exp, stack)
  # puts "#{exp} #{stack}"

  if exp.empty?
    return stack.pop if stack.size == 1
    return nil
  end

  val = exp.shift
  return nil if val.nil?
  if val.class == Fixnum
    stack.push(val)
    return calc_rev_polish(exp, stack)
  end

  a = stack.pop
  b = stack.pop
  return nil if b.nil?
  if val == "+"
    stack.push(b+a)
  elsif val == "-"
    stack.push(b-a)
  else
    stack.push(b*a)
  end
  return calc_rev_polish(exp, stack)
    
end

def find_prev_term(exp, pos)
  par_count = 0
  pos.downto(0){|p|
    if p <= 0
      return p
    end

    if exp[p].class == Fixnum && par_count == 0
      return p
    end

    if exp[p] == ")"
      par_count += 1
    end

    if exp[p] == "("
      par_count -= 1
      if par_count == 0
        return p
      end
    end
  }

end

def rev2norm(rev)
  norm = []

  rev.each{|v|
    if v.class == Fixnum
      norm.push(v)
      next
    end

    pos1 = find_prev_term(norm, norm.size-1)
    norm.insert(pos1, v)

    pos2 = find_prev_term(norm, pos1-1)
    norm.insert(pos2, "(")
    norm.push(")")

    # p norm
  }
  return norm
end

ARGF.each{|line|
  problem = line.chomp.split(/ /).map{|c| c.to_i} + "+++---***".split(//)
  break if line.chomp == "0 0 0 0"

  out = nil
  problem.permutation(7){|exp|
    exp2 = exp.dup
    if calc_rev_polish(exp, []) == 10
      out = exp2
      break
    end
  }
  if out.nil?
    puts "0"
  else
    # p out
    puts rev2norm(out).join("")
  end
}
  