def calculate(cards, target): # print(cards, target) global op_list if len(cards) == 1: if cards[0] == target: return cards else: return False for i in cards: # print("current i:", i) remaining_cards = cards.copy() remaining_cards.remove(i) # +: ans = calculate(remaining_cards, target - i) if ans is not False: ans.append(i) op_list.append("+") return ans # -: ans = calculate(remaining_cards, target + i) if ans is not False: ans.append(i) op_list.append("-") return ans # /: ans = calculate(remaining_cards, target * i) if ans is not False: ans.append(i) op_list.append("/") return ans # *: if target % i == 0: ans = calculate(remaining_cards, target // i) if ans is not False: ans.append(i) op_list.append("*") return ans return False # 表示算不出来 while True: try: l = input().split() if "joker" in l or "JOKER" in l: print("ERROR") cards = [] dic = {"J": 11, "Q":12, 'K':13, "A":1} for i in l: if i in dic: cards.append(dic[i]) else: cards.append(int(i)) # print(cards) # 把一个数字放到最后,看前三个数字的结果加减乘除能不能得到24. op_list = [] ans = calculate(cards, 24) if ans is False: print("NONE") else: res = "" for i in range(3): if ans[i] == 11: res += "J" + op_list[i] elif ans[i] == 12: res += "Q" + op_list[i] elif ans[i] == 13: res += "K" + op_list[i] elif ans[i] == 1: res += "A" + op_list[i] else: res += str(ans[i]) + op_list[i] if ans[3] == 11: res += "J" + op_list[i] elif ans[3] == 12: res += "Q" + op_list[i] elif ans[3] == 13: res += "K" + op_list[i] elif ans[3] == 1: res += "A" + op_list[i] else: res += str(ans[3]) print(res) except: break