import itertools
def fun(a, b, c, d):
card_dict = {
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 9,
'10': 10,
'J': 11,
'Q': 12,
'K': 13,
'A': 1
}
rules = ['+', '-', '*', '/']
# 把牌面转为整数
x, y, z, m = card_dict[a], card_dict[b], card_dict[c], card_dict[d]
# 一组数字计算中有三个加减乘除符号,计算所有可能性
for i in rules:
for j in rules:
for k in rules:
# 因为是从左往右计算,把前面的括起来
result = eval('((' + 'x' + i + 'y' + ')' + j + 'z' + ')' + k + 'm')
if result == 24:
return a + i + b + j + c + k + d
else:
return False
while True:
try:
card_list = input().split()
if 'joker' in card_list or 'JOKER' in card_list:
print('ERROR')
else:
# 所有的牌面顺序
all_list = itertools.permutations(card_list)
for each in all_list:
a, b, c, d = each
result = fun(a, b, c, d)
if result:
print(result)
else:
print('NONE')
except:
break