Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be output. If there is no answer, output 0.

* Use only addition (+), subtraction (-), and multiplication (*) as operators. Do not use division (/). You can use three operators.
* You must use all four numbers.
* You can freely change the order of the four numbers.
* You can use parentheses. You can use up to 3 sets (6) of parentheses.



Input

Given multiple datasets. The format of each dataset is as follows:


a b c d

Input ends with four 0s. The number of datasets does not exceed 40.

Output

For each dataset, combine the given four integers with the above arithmetic symbols and parentheses to output an expression or 0 with a value of 10 on one line. The expression string must not exceed 1024 characters.

Example

Input

8 7 9 9
4 4 4 4
5 5 7 5
0 0 0 0


Output

((9 * (9 - 7)) - 8)
0
((7 * 5) - (5 * 5))

Source: aizu | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
from itertools import permutations, product
import sys
readline = sys.stdin.readline
write = sys.stdout.write
P = ['((%d %s %d) %s (%d %s %d))', '(%d %s (%d %s (%d %s %d)))', '(((%d %s %d) %s %d) %s %d)', '((%d %s (%d %s %d)) %s %d)', '(%d %s ((%d %s %d) %s %d))']

def solve():
	(*X,) = map(int, readline().split())
	if X[0] == 0:
		return False
	for Y in permutations(X):
		for ops in product('+-*', repeat=3):
			r = []
			for (y, op) in zip(Y, ops):
				r.append(y)
				r.append(op)
			r.append(Y[-1])
			for p in P:
				s = p % tuple(r)
				if eval(s) == 10:
					write('%s\n' % s)
					return True
	write('0\n')
	return True
while solve():
	...


import itertools

def calc(n):
	for op in itertools.product(operators, repeat=3):
		for form in forms:
			formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
			if eval(formula) == 10:
				print(formula)
				return True
	return False
operators = ('+', '-', '*')
forms = ('(({3}{0}{4}){1}{5}){2}{6}', '({3}{0}{4}){1}({5}{2}{6})', '({3}{0}({4}{1}{5})){2}{6}', '{3}{0}(({4}{1}{5}){2}{6})', '{3}{0}({4}{1}({5}{2}{6}))')
while True:
	nums = tuple(map(int, input().split()))
	if nums == (0, 0, 0, 0):
		break
	for n in itertools.permutations(nums):
		if calc(n):
			break
	else:
		print(0)


from itertools import *

def g(a, x, b):
	return a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			if g(g(a, x, g(b, y, c)), z, d) == 10:
				return f'(({a} {x} ({b} {y} {c})) {z} {d})'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import sys
from itertools import permutations, product

def make_ten(digits):
	result = '0'
	for (a, b, c, d) in permutations(digits, 4):
		if result != '0':
			break
		for (op1, op2, op3) in product(['+', '-', '*'], repeat=3):
			exp = '(({} {} {}) {} {}) {} {}'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} ({} {} {})) {} {})'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} (({} {} {}) {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} ({} {} ({} {} {})))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
	return result
Memo = {}

def solve(digits):
	global Memo
	digits.sort(reverse=True)
	data = ''.join(map(str, digits))
	if not data in Memo:
		Memo[data] = make_ten(digits)
	return Memo[data]

def main(args):
	while True:
		digits = [int(x) for x in input().strip().split(' ')]
		if digits[0] == 0 and digits[1] == 0 and (digits[2] == 0) and (digits[3] == 0):
			break
		result = solve(digits)
		print(result)
main(sys.argv[1:])


import itertools, sys

def f(a):
	if len(a) < 2:
		yield ([a[0]] * 2)
	for i in range(1, len(a)):
		for (p, s) in f(a[:i]):
			for (q, t) in f(a[i:]):
				yield (p + q, f'({s} + {t})')
				yield (p - q, f'({s} - {t})')
				yield (p * q, f'({s} * {t})')

def s(a):
	for p in itertools.permutations(a):
		for (n, s) in f(p):
			if n == 10:
				print(s)
				return 1
for e in iter(input, '0 0 0 0'):
	a = list(map(int, e.split()))
	if not s(a):
		print(0)


import itertools

def f(s):
	for (a, b, c, d) in itertools.permutations(s):
		for (x, y, z) in itertools.product('+-*', repeat=3):
			yield f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			yield f'((({a} {x} {b}) {y} {c}) {z} {d})'
			yield f'({a} {x} ({b} {y} ({c} {z} {d})))'
			yield f'(({a} {x} ({b} {y} {c})) {z} {d})'
			yield f'({a} {x} (({b} {y} {c}) {z} {d}))'
for e in iter(input, '0 0 0 0'):
	s = list(map(int, e.split()))
	a = 0
	for m in f(s):
		if eval(m) == 10:
			a = m
			break
	print(a)


from itertools import product, permutations
expr_a = ('{}{}{}{}{}{}{}', '({}{}{}){}{}{}{}', '{}{}({}{}{}){}{}', '{}{}{}{}({}{}{})', '({}{}{}){}({}{}{})')
while True:
	a = list(map(int, input().split()))
	if a == [0, 0, 0, 0]:
		break
	flag = False
	for ((op1, op2, op3), (n1, n2, n3, n4)) in product(product('+-*', repeat=3), permutations(a)):
		inner = (n1, op1, n2, op2, n3, op3, n4)
		for expr in expr_a:
			if eval(expr.format(*inner)) == 10:
				print(expr.format(*inner))
				flag = True
				break
		if flag:
			break
	if not flag:
		print(0)


import itertools
while 1:
	try:
		n = list(map(int, input().split()))
		if n[0] + n[1] + n[2] + n[3] == 0:
			break
		n_l = list(itertools.permutations(n))
		marks = ['+', '-', '*']
		flag = 0
		for i in n_l:
			if flag == 1:
				break
			for m1 in marks:
				if flag == 1:
					break
				for m2 in marks:
					if flag == 1:
						break
					for m3 in marks:
						if flag == 1:
							break
						l = f'(({i[0]}{m1}{i[1]}){m2}({i[2]}{m3}{i[3]}))'
						if eval(l) == 10:
							flag = 1
							break
						l = f'((({i[0]}{m1}{i[1]}){m2}{i[2]}){m3}{i[3]})'
						if eval(l) == 10:
							flag = 1
							break
						l = f'(({i[0]}{m1}({i[1]}{m2}{i[2]})){m3}{i[3]})'
						if eval(l) == 10:
							flag = 1
							break
		if flag == 0:
			l = 0
		print(l)
	except:
		break


from itertools import *
g = lambda a, x, b: {'+': a + b, '-': a - b, '*': a * b}[x]

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(g(a, x, b), y, c), z, d) == 10:
				return f'(({a}{x}{b}){y}{c}){z}{d}'
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'({a}{x}{b}){y}({c}{z}{d})'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(g(a, x, b), y, c), z, d) == 10:
				return f'(({a} {x} {b}) {y} {c}) {z} {d}'
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'({a} {x} {b}) {y} ({c} {z} {d})'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import *

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'({a} {x} ({b} {y} {c})) {z} {d}']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import sys
import itertools

def line():
	return sys.stdin.readline().strip()
p = ['+', '-', '*']
n = [[0, 2, 0, 1], [0, 2, 1, 2], [1, 3, 1, 2], [1, 3, 2, 3], [0, 1, 2, 3]]

def f(l):
	for i in range(len(n)):
		L = l[:]
		L[n[i][0]] = '(' + L[n[i][0]]
		L[n[i][1]] = L[n[i][1]] + ')'
		L[n[i][2]] = '(' + L[n[i][2]]
		L[n[i][3]] = L[n[i][3]] + ')'
		for i in range(3):
			for j in range(3):
				for k in range(3):
					N = L[:]
					N[0] += p[i]
					N[1] += p[j]
					N[2] += p[k]
					e = ' '.join(N)
					exec('x=' + e, globals())
					if x == 10:
						return e
	return '0'
while True:
	l = line().split()
	if l[0] == '0':
		break
	ans = '0'
	for i in list(itertools.permutations(l)):
		i = f(list(i))
		if i != '0':
			ans = i
			break
	print(ans)


from itertools import permutations

def testcase_ends():
	(a, b, c, d) = map(int, input().split())
	if (a, b, c, d) == (0, 0, 0, 0):
		return True
	operators = '+-*'
	expressions = ['((({0} {1} {2}) {3} {4}) {5} {6})', '(({0} {1} ({2} {3} {4})) {5} {6})', '(({0} {1} {2}) {3} ({4} {5} {6}))', '({0} {1} ({2} {3} ({4} {5} {6})))', '({0} {1} (({2} {3} {4}) {5} {6}))']
	for s in operators:
		for t in operators:
			for u in operators:
				for x in expressions:
					for p in permutations([a, b, c, d]):
						(a, b, c, d) = p
						f = x.format(a, s, b, t, c, u, d)
						if eval(f) == 10:
							print(f)
							return False
	print(0)
	return False
while not testcase_ends():
	pass


from itertools import permutations
while 1:
	a_ = [int(i) for i in input().split()]
	if a_ == [0, 0, 0, 0]:
		break
	p = list((list(i) for i in permutations(a_)))
	cont = 1
	for (a, b, c, d) in p:
		if cont == 0:
			break
		for i in ('+', '-', '*'):
			if cont == 0:
				break
			for j in ('+', '-', '*'):
				if cont == 0:
					break
				for k in ('+', '-', '*'):
					if cont == 0:
						break
					p = 0
					if exec('p = (a{}b){}c{}d'.format(i, j, k)) is None and p == 10:
						print('({0}{4}{1}){5}{2}{6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = (a{}b{}c){}d'.format(i, j, k)) is None and p == 10:
						print('({0}{4}{1}{5}{2}){6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}(b{}c){}d'.format(i, j, k)) is None and p == 10:
						print('{0}{4}({1}{5}{2}){6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}(b{}c{}d)'.format(i, j, k)) is None and p == 10:
						print('{0}{4}({1}{5}{2}{6}{3})'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}b{}(c{}d)'.format(i, j, k)) is None and p == 10:
						print('{0}{4}{1}{5}({2}{6}{3})'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = ((a{}b){}c){}d'.format(i, j, k)) is None and p == 10:
						print('(({0}{4}{1}){5}{2}){6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = (a{}b){}(c{}d)'.format(i, j, k)) is None and p == 10:
						print('({0}{4}{1}){5}({2}{6}{3})'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}((b{}c){}d)'.format(i, j, k)) is None and p == 10:
						print('{0}{4}(({1}{5}{2}){6}{3})'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = (a{}(b{}c)){}d'.format(i, j, k)) is None and p == 10:
						print('({0}{4}({1}{5}{2})){6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}(b{}(c{}d))'.format(i, j, k)) is None and p == 10:
						print('{0}{4}({1}{5}({2}{6}{3}))'.format(a, b, c, d, i, j, k))
						cont = 0
					elif exec('p = a{}b{}c{}d'.format(i, j, k)) is None and p == 10:
						print('{0}{4}{1}{5}{2}{6}{3}'.format(a, b, c, d, i, j, k))
						cont = 0
	if cont == 1:
		print('0')


import sys
import os
import math
import itertools
commands = ['({}{}{}) {}{}{}{}', '{}{} ({}{}{}) {}{}', '{}{}{}{} ({}{}{})', '( ({}{}{}) {}{}) {}{}', '{}{} ({}{} ({}{}{}) )', '({}{}{}) {} ({}{}{})']
for s in sys.stdin:
	(a, b, c, d) = map(int, s.split())
	if a == b == c == d == 0:
		pass
	else:
		solved = False
		for values in itertools.permutations([a, b, c, d], 4):
			if solved:
				break
			for operators in itertools.product(['+', '-', '*'], repeat=3):
				if solved:
					break
				for command_template in commands:
					if solved:
						break
					command = command_template.format(values[0], operators[0], values[1], operators[1], values[2], operators[2], values[3])
					result = eval(command)
					if result == 10:
						print(command)
						solved = True
		if not solved:
			print(0)


import itertools

def f(s):
	for (a, b, c, d) in itertools.permutations(s):
		for (x, y, z) in itertools.product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'{a} {x} ({b} {y} ({c} {z} {d}))', f'({a} {x} ({b} {y} {c})) {z} {d}', f'{a} {x} (({b} {y} {c}) {z} {d})']:
				if eval(t) == 10:
					return t
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	s = list(map(int, e.split()))
	a = f(s)
	if a:
		print('(' + a + ')')
	else:
		print(a)


from itertools import product, permutations
while True:
	a = list(map(int, input().split()))
	if a == [0, 0, 0, 0]:
		break
	flag = False
	for (op1, op2, op3) in product('+-*', repeat=3):
		for (n1, n2, n3, n4) in permutations(a):
			expr_base = '{}{}{}{}{}{}{}'.format(n1, op1, n2, op2, n3, op3, n4)
			for expr in (expr_base, '(' + expr_base[:3] + ')' + expr_base[3:], expr_base[:2] + '(' + expr_base[2:5] + ')' + expr_base[5:], expr_base[:4] + '(' + expr_base[4:] + ')', '(' + expr_base[:3] + ')' + expr_base[3] + '(' + expr_base[4:] + ')'):
				if eval(expr) == 10:
					print(expr)
					flag = True
					break
			if flag:
				break
		if flag:
			break
	if not flag:
		print(0)


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('*+-', repeat=3):
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			if g(g(a, x, g(b, y, c)), z, d) == 10:
				return f'(({a} {x} ({b} {y} {c})) {z} {d})'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import sys, itertools
if sys.version_info[0] >= 3:
	raw_input = input

def dfs(a):
	if len(a) < 2:
		yield (a[0], str(a[0]))
	for i in range(len(a) - 1):
		for l in dfs(a[:i + 1]):
			for r in dfs(a[i + 1:]):
				yield (l[0] + r[0], '(%s + %s)' % (l[1], r[1]))
				yield (l[0] - r[0], '(%s - %s)' % (l[1], r[1]))
				yield (l[0] * r[0], '(%s * %s)' % (l[1], r[1]))

def solve(a):
	for e in itertools.permutations(a):
		for (n, s) in dfs(e):
			if n == 10:
				print(s)
				return True
try:
	while True:
		a = [int(e) for e in raw_input().split()]
		if a == [0, 0, 0, 0]:
			break
		if not solve(a):
			print(0)
except EOFError:
	pass


import itertools

def f(s):
	for (a, b, c, d) in itertools.permutations(s):
		for (x, y, z) in itertools.product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'{a} {x} ({b} {y} ({c} {z} {d}))', f'({a} {x} ({b} {y} {c})) {z} {d}', f'{a} {x} (({b} {y} {c}) {z} {d})']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(g(a, x, b), y, c), z, d) == 10:
				return f'((({a} {x} {b}) {y} {c}) {z} {d})'
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
	return 0
[print(f(list(map(int, e.split())))) for e in iter(input, '0 0 0 0')]


import itertools
Ops = ['+', '-', '*']
Formulae = ['(({3}{0}{4}){1}{5}){2}{6}', '({3}{0}{4}){1}({5}{2}{6})', '({3}{0}({4}{1}{5})){2}{6}', '{3}{0}(({4}{1}{5}){2}{6})', '{3}{0}({4}{1}({5}{2}{6}))']
while True:
	nums = list(map(int, input().split()))
	if nums == [0, 0, 0, 0]:
		break
	flag = False
	for numpair in itertools.permutations(nums):
		if flag:
			break
		for op in itertools.product(Ops, repeat=3):
			if flag:
				break
			for form in Formulae:
				if eval(form.format(op[0], op[1], op[2], numpair[0], numpair[1], numpair[2], numpair[3])) == 10:
					print(form.format(op[0], op[1], op[2], numpair[0], numpair[1], numpair[2], numpair[3]))
					flag = True
					break
	else:
		print(0)


import itertools, sys

def f(s):
	for (a, b, c, d) in itertools.permutations(s):
		for (x, y, z) in itertools.product('+-*', repeat=3):
			yield f'({a} {x} {b}) {y} ({c} {z} {d})'
			yield f'(({a} {x} {b}) {y} {c}) {z} {d}'
			yield f'{a} {x} ({b} {y} ({c} {z} {d}))'
			yield f'({a} {x} ({b} {y} {c})) {z} {d}'
			yield f'{a} {x} (({b} {y} {c}) {z} {d})'
for e in sys.stdin:
	s = list(map(int, e.split()))
	a = 0
	if sum(s) == 0:
		break
	for m in f(s):
		if eval(m) == 10:
			a = '(' + m + ')'
			break
	print(a)


import sys
import itertools

def line():
	return sys.stdin.readline().strip()
p = ['+', '-', '*']
n = [[0, 2, 0, 1], [0, 1, 2, 3]]

def f(l):
	for i in range(len(n)):
		L = l[:]
		L[n[i][0]] = '(' + L[n[i][0]]
		L[n[i][1]] = L[n[i][1]] + ')'
		L[n[i][2]] = '(' + L[n[i][2]]
		L[n[i][3]] = L[n[i][3]] + ')'
		for i in range(3):
			for j in range(3):
				for k in range(3):
					N = L[:]
					N[0] += p[i]
					N[1] += p[j]
					N[2] += p[k]
					e = ' '.join(N)
					exec('x=' + e, globals())
					if x == 10:
						return e
	return '0'
while True:
	l = line().split()
	if l[0] == '0':
		break
	ans = '0'
	for i in list(itertools.permutations(l)):
		i = f(list(i))
		if i != '0':
			ans = i
			break
	print(ans)


import itertools
operators = ('+', '-', '*')
forms = ('(({3}{0}{4}){1}{5}){2}{6}', '({3}{0}{4}){1}({5}{2}{6})', '({3}{0}({4}{1}{5})){2}{6}', '{3}{0}(({4}{1}{5}){2}{6})', '{3}{0}({4}{1}({5}{2}{6}))')

def calc(n):
	for op in itertools.product(operators, repeat=3):
		for form in forms:
			formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
			if eval(formula) == 10:
				print(formula)
				return True
	return False
while True:
	num = list(map(int, input().split()))
	if num[0] == 0:
		break
	for n in itertools.permutations(num):
		if calc(n):
			break
	else:
		print(0)


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			if g(g(a, x, g(b, y, c)), z, d) == 10:
				return f'(({a} {x} ({b} {y} {c})) {z} {d})'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import itertools
while True:
	data = input().split()
	if not sum(map(int, data)):
		break
	for num in itertools.permutations(data, 4):
		for oprs in itertools.product([' + ', ' - ', ' * '], repeat=3):
			if eval('(' + num[0] + oprs[0] + num[1] + ')' + oprs[1] + '(' + num[2] + oprs[2] + num[3] + ')') == 10:
				print('(' + num[0] + oprs[0] + num[1] + ')' + oprs[1] + '(' + num[2] + oprs[2] + num[3] + ')')
				break
			if eval('(' + '(' + num[0] + oprs[0] + num[1] + ')' + oprs[1] + num[2] + ')' + oprs[2] + num[3]) == 10:
				print('(' + '(' + num[0] + oprs[0] + num[1] + ')' + oprs[1] + num[2] + ')' + oprs[2] + num[3])
				break
			if eval('(' + num[0] + oprs[0] + '(' + num[1] + oprs[1] + num[2] + ')' + ')' + oprs[2] + num[3]) == 10:
				print('(' + num[0] + oprs[0] + '(' + num[1] + oprs[1] + num[2] + ')' + ')' + oprs[2] + num[3])
				break
			if eval(num[0] + oprs[0] + '(' + '(' + num[1] + oprs[1] + num[2] + ')' + oprs[2] + num[3] + ')') == 10:
				print(num[0] + oprs[0] + '(' + '(' + num[1] + oprs[1] + num[2] + ')' + oprs[2] + num[3] + ')')
				break
			if eval(num[0] + oprs[0] + '(' + num[1] + oprs[1] + '(' + num[2] + oprs[2] + num[3] + ')' + ')') == 10:
				print(num[0] + oprs[0] + '(' + num[1] + oprs[1] + '(' + num[2] + oprs[2] + num[3] + ')' + ')')
				break
		else:
			continue
		break
	else:
		print(0)


from itertools import *

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import itertools

def calc(a, b, c):
	if c == 0:
		return a + b
	elif c == 1:
		return a - b
	else:
		return a * b
mp = [' + ', ' - ', ' * ']
while True:
	nums = list(map(int, input().split()))
	if nums[0] == 0 and nums[1] == 0 and (nums[2] == 0) and (nums[3] == 0):
		break
	nums.sort()
	ans = ''
	for perms in itertools.permutations(nums):
		perms = list(perms)
		v = [0, 0, 0]
		for v[0] in range(3):
			for v[1] in range(3):
				for v[2] in range(3):
					sum = calc(perms[0], perms[1], v[0])
					sum = calc(sum, perms[2], v[1])
					sum = calc(sum, perms[3], v[2])
					for i in range(4):
						perms[i] = str(perms[i])
					if sum == 10:
						ans = '((' + perms[0] + mp[v[0]] + perms[1] + ')' + mp[v[1]] + perms[2] + ')' + mp[v[2]] + perms[3]
					for i in range(4):
						perms[i] = int(perms[i])
		for v[0] in range(3):
			for v[1] in range(3):
				for v[2] in range(3):
					lsum = calc(perms[0], perms[1], v[0])
					rsum = calc(perms[2], perms[3], v[2])
					sum = calc(lsum, rsum, v[1])
					for i in range(4):
						perms[i] = str(perms[i])
					if sum == 10:
						ans = '(' + perms[0] + mp[v[0]] + perms[1] + ')' + mp[v[1]] + '(' + perms[2] + mp[v[2]] + perms[3] + ')'
					for i in range(4):
						perms[i] = int(perms[i])
		for v[0] in range(3):
			for v[1] in range(3):
				for v[2] in range(3):
					sum = calc(perms[1], perms[2], v[1])
					sum = calc(perms[0], sum, v[0])
					sum = calc(sum, perms[3], v[2])
					for i in range(4):
						perms[i] = str(perms[i])
					if sum == 10:
						ans = '(' + perms[0] + mp[v[0]] + '(' + perms[1] + mp[v[1]] + perms[2] + '))' + mp[v[2]] + perms[3]
					for i in range(4):
						perms[i] = int(perms[i])
		for v[0] in range(3):
			for v[1] in range(3):
				for v[2] in range(3):
					sum = calc(perms[2], perms[3], v[2])
					sum = calc(perms[1], sum, v[1])
					sum = calc(perms[0], sum, v[0])
					for i in range(4):
						perms[i] = str(perms[i])
					if sum == 10:
						ans = perms[0] + mp[v[0]] + '(' + perms[1] + mp[v[1]] + '(' + perms[2] + mp[v[2]] + perms[3] + '))'
					for i in range(4):
						perms[i] = int(perms[i])
	if len(ans) == 0:
		print(0)
	else:
		print(ans)


import itertools

def func(n):
	for op in itertools.product(operators, repeat=3):
		for form in forms:
			formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
			if eval(formula) == 10:
				print(formula)
				return True
	return False
operators = ('+', '-', '*')
forms = ('(({3}{0}{4}){1}{5}){2}{6}', '({3}{0}{4}){1}({5}{2}{6})', '({3}{0}({4}{1}{5})){2}{6}', '{3}{0}(({4}{1}{5}){2}{6})', '{3}{0}({4}{1}({5}{2}{6}))')
while True:
	nums = tuple(map(int, input().split()))
	if nums == (0, 0, 0, 0):
		break
	for n in itertools.permutations(nums):
		if func(n):
			break
	else:
		print(0)


from sys import stdin
from itertools import permutations, product
while True:
	lis = stdin.readline().split()
	if lis == ['0', '0', '0', '0']:
		break
	for ([a, b, c, d], [e, f, g], h) in product(permutations(lis), product(['+', '*', '-'], repeat=3), range(7)):
		st = '(' * (h >> 2) + a + e + '(' * (1 if h in [2, 3] else 0) + b + ')' * (1 if h in [4, 5] else 0) + f + '(' * (1 if h in [1, 5] else 0) + c + ')' * (1 if h in [2, 6] else 0) + g + d + ')' * (h & 5 >> 2)
		if eval(st) == 10:
			print(st)
			break
	else:
		print(0)


from itertools import permutations

def g(a):
	if len(a) == 1:
		yield str(a[0])
	for i in range(1, len(a)):
		for l in g(a[:i]):
			for r in g(a[i:]):
				yield '({}+{})'.format(l, r)
				yield '({}-{})'.format(l, r)
				yield '({}*{})'.format(l, r)

def solve(a):
	for e in permutations(a):
		for s in g(e):
			if eval(s) == 10:
				return s
	return '0'
while True:
	a = list(map(int, input().split()))
	if a == [0, 0, 0, 0]:
		break
	print(solve(a))


import sys
from itertools import permutations, product

def has_possibility(digits):
	result = False
	digits.sort(reverse=True)
	total = digits[0]
	for i in digits[1:]:
		if i < 2:
			total += i
		else:
			total *= i
	if total >= 10:
		result = True
	return result

def make_ten(digits):
	result = '0'
	for (a, b, c, d) in permutations(digits, 4):
		if result != '0':
			break
		for (op1, op2, op3) in product(['+', '-', '*'], repeat=3):
			exp = '((({} {} {}) {} {}) {} {})'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} ({} {} {})) {} {})'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} (({} {} {}) {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} ({} {} ({} {} {})))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
	return result

def do_calc(x, y, op):
	result = None
	if op == '+':
		result = x + y
	elif op == '-':
		result = x - y
	elif op == '*':
		result = x * y
	return result
Memo = {}

def solve(digits):
	global Memo
	digits.sort(reverse=True)
	data = ''.join(map(str, digits))
	if data in Memo:
		pass
	else:
		Memo[data] = make_ten(digits)
	return Memo[data]

def main(args):
	while True:
		digits = [int(x) for x in input().strip().split(' ')]
		if digits[0] == 0 and digits[1] == 0 and (digits[2] == 0) and (digits[3] == 0):
			break
		result = solve(digits)
		print(result)
main(sys.argv[1:])


import itertools

def f(s):
	for (x, y, z) in itertools.product('+-*', repeat=3):
		for (a, b, c, d) in itertools.permutations(s):
			yield f'({a} {x} {b}) {y} ({c} {z} {d})'
			yield f'(({a} {x} {b}) {y} {c}) {z} {d}'
			yield f'{a} {x} ({b} {y} ({c} {z} {d}))'
			yield f'({a} {x} ({b} {y} {c})) {z} {d}'
			yield f'{a} {x} (({b} {y} {c}) {z} {d})'
for e in iter(input, '0 0 0 0'):
	s = list(map(int, e.split()))
	a = 0
	for m in f(s):
		if eval(m) == 10:
			a = '(' + m + ')'
			break
	print(a)


from itertools import *

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'({a} {x} ({b} {y} {c})) {z} {d}']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from collections import deque

def calculate1(x, y):
	if x == 0:
		y.appendleft(y.popleft() + y.popleft())
	elif x == 1:
		y.appendleft(y.popleft() - y.popleft())
	else:
		y.appendleft(y.popleft() * y.popleft())
	return y

def calculate2(x, y):
	if x == 0:
		y.append(y.pop() + y.pop())
	elif x == 1:
		y.append(-y.pop() + y.pop())
	else:
		y.append(y.pop() * y.pop())
	return y

def search1(sample):
	for first in range(3):
		for second in range(3):
			for third in range(3):
				box = deque(sample)
				calculate1(first, box)
				calculate1(second, box)
				calculate1(third, box)
				if box[0] == 10:
					return (first, second, third)
					break

def search2(sample):
	for first in range(3):
		for second in range(3):
			for third in range(3):
				box = deque(sample)
				calculate1(first, box)
				calculate2(second, box)
				calculate1(third, box)
				if box[0] == 10:
					return (first, second, third)
					break

def attack(sample):
	test = [[sample[a], sample[b], sample[c], sample[d]] for a in range(4) for b in range(4) for c in range(4) for d in range(4) if a != b and a != c and (a != d) and (b != c) and (b != d) and (c != d)]
	test = list(set(map(tuple, test)))
	for _ in test:
		result = search1(_)
		if result != None:
			return (result, _, 1)
			break
		else:
			result = search2(_)
			if result != None:
				return (result, _, 2)
				break
ams = ['+', '-', '*']
while True:
	sample = [int(_) for _ in input().split()]
	if sample == [0, 0, 0, 0]:
		break
	result = attack(sample)
	if result != None:
		if result[2] == 1:
			print('((({} {} {}) {} {}) {} {})'.format(result[1][0], ams[result[0][0]], result[1][1], ams[result[0][1]], result[1][2], ams[result[0][2]], result[1][3]))
		else:
			print('(({} {} {}) {} ({} {} {}))'.format(result[1][0], ams[result[0][0]], result[1][1], ams[result[0][2]], result[1][2], ams[result[0][1]], result[1][3]))
	else:
		print(0)


from itertools import permutations

def test():
	(a, b, c, d) = map(int, input().split())
	if (a, b, c, d) == (0, 0, 0, 0):
		return True
	operators = '+-*'
	expressions = ['((({0} {1} {2}) {3} {4}) {5} {6})', '(({0} {1} ({2} {3} {4})) {5} {6})', '(({0} {1} {2}) {3} ({4} {5} {6}))', '({0} {1} ({2} {3} ({4} {5} {6})))', '({0} {1} (({2} {3} {4}) {5} {6}))']
	for s in operators:
		for t in operators:
			for u in operators:
				for x in expressions:
					for p in permutations([a, b, c, d]):
						(a, b, c, d) = p
						f = x.format(a, s, b, t, c, u, d)
						if eval(f) == 10:
							print(f)
							return False
	print(0)
	return False
while not test():
	pass


import itertools

def f(s):
	for (a, b, c, d) in itertools.permutations(s):
		for (x, y, z) in itertools.product('+-*', repeat=3):
			yield f'({a} {x} {b}) {y} ({c} {z} {d})'
			yield f'(({a} {x} {b}) {y} {c}) {z} {d}'
			yield f'{a} {x} ({b} {y} ({c} {z} {d}))'
			yield f'({a} {x} ({b} {y} {c})) {z} {d}'
			yield f'{a} {x} (({b} {y} {c}) {z} {d})'
for e in iter(input, '0 0 0 0'):
	s = list(map(int, e.split()))
	a = 0
	for m in f(s):
		if eval(m) == 10:
			a = '(' + m + ')'
			break
	print(a)


import itertools, sys

def f(a):
	if len(a) < 2:
		yield (a[0], a[0])
	for i in range(1, len(a)):
		for (p, s) in f(a[:i]):
			for (q, t) in f(a[i:]):
				yield (p + q, f'({s} + {t})')
				yield (p - q, f'({s} - {t})')
				yield (p * q, f'({s} * {t})')

def s(a):
	for p in itertools.permutations(a):
		for (n, s) in f(p):
			if n == 10:
				print(s)
				return 1
for e in sys.stdin:
	a = list(map(int, e.split()))
	if sum(a) and (not s(a)):
		print(0)


from itertools import *

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'{a} {x} ({b} {y} ({c} {z} {d}))', f'({a} {x} ({b} {y} {c})) {z} {d}', f'{a} {x} (({b} {y} {c}) {z} {d})']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('-*+', repeat=3):
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			if g(g(a, x, g(b, y, c)), z, d) == 10:
				return f'(({a} {x} ({b} {y} {c})) {z} {d})'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import permutations
brackets = [((0, '('), (3, ')')), ((2, '('), (5, ')')), ((4, '('), (7, ')')), ((0, '('), (3, ')'), (4, '('), (7, ')')), ((0, '('), (0, '('), (3, ')'), (5, ')')), ((0, '('), (2, '('), (5, ')'), (5, ')')), ((2, '('), (2, '('), (5, ')'), (7, ')')), ((2, '('), (4, '('), (7, ')'), (7, ')'))]
ops = []
for op1 in ('+', '-', '*'):
	for op2 in ('+', '-', '*'):
		for op3 in ('+', '-', '*'):
			ops.append((op1, op2, op3))

def check(lst):
	for num_lst in permutations(lst, 4):
		for op_lst in ops:
			for br_lst in brackets:
				new = list(num_lst)
				for (i, op) in enumerate(reversed(op_lst)):
					new.insert(3 - i, op)
				for (ind, br) in reversed(br_lst):
					new.insert(ind, br)
				exp = ''.join(new)
				if eval(exp) == 10:
					return exp
	return 0
while True:
	lst = list(input().split())
	if lst == ['0', '0', '0', '0']:
		break
	print(check(lst))


from itertools import *

def f(s):
	if sum(s) == 10:
		return '((({} + {}) + {}) + {})'.format(*s)
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in permutations('+-*+-*', 3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'({a} {x} ({b} {y} {c})) {z} {d}']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import sys
from itertools import permutations, product

def make_ten(digits):
	result = '0'
	for (a, b, c, d) in permutations(digits, 4):
		if result != '0':
			break
		for (op1, op2, op3) in product(['+', '-', '*'], repeat=3):
			exp = '((({} {} {}) {} {}) {} {})'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} ({} {} {})) {} {})'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} (({} {} {}) {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '({} {} ({} {} ({} {} {})))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
			exp = '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
			if eval(exp) == 10:
				result = exp
				break
	return result
Memo = {}

def solve(digits):
	global Memo
	digits.sort(reverse=True)
	data = ''.join(map(str, digits))
	if data in Memo:
		pass
	else:
		Memo[data] = make_ten(digits)
	return Memo[data]

def main(args):
	while True:
		digits = [int(x) for x in input().strip().split(' ')]
		if digits[0] == 0 and digits[1] == 0 and (digits[2] == 0) and (digits[3] == 0):
			break
		result = solve(digits)
		print(result)
main(sys.argv[1:])


from itertools import *

def f(s):
	if sum(s) == 10:
		return '((({} + {}) + {}) + {})'.format(*s)
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in permutations('+-*' * 2, 3):
			for t in [f'({a} {x} {b}) {y} ({c} {z} {d})', f'(({a} {x} {b}) {y} {c}) {z} {d}', f'({a} {x} ({b} {y} {c})) {z} {d}']:
				if eval(t) == 10:
					return '(' + t + ')'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
			if g(g(a, x, g(b, y, c)), z, d) == 10:
				return f'(({a} {x} ({b} {y} {c})) {z} {d})'
	else:
		return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))


import itertools, sys

def f(a):
	if len(a) < 2:
		yield ([a[0]] * 2)
	for i in range(1, len(a)):
		for (p, s) in f(a[:i]):
			for (q, t) in f(a[i:]):
				yield (p + q, f'({s} + {t})')
				yield (p - q, f'({s} - {t})')
				yield (p * q, f'({s} * {t})')

def s(a):
	for p in itertools.permutations(a):
		for (n, s) in f(p):
			if n == 10:
				print(s)
				return 1
for e in sys.stdin:
	a = list(map(int, e.split()))
	if sum(a) and (not s(a)):
		print(0)


from itertools import *
g = lambda a, x, b: a + b if x == '+' else a - b if x == '-' else a * b

def f(s):
	for (a, b, c, d) in permutations(s):
		for (x, y, z) in product('+-*', repeat=3):
			if g(g(g(a, x, b), y, c), z, d) == 10:
				return f'((({a} {x} {b}) {y} {c}) {z} {d})'
			if g(g(a, x, b), y, g(c, z, d)) == 10:
				return f'(({a} {x} {b}) {y} ({c} {z} {d}))'
	return 0
for e in iter(input, '0 0 0 0'):
	print(f(list(map(int, e.split()))))