import java.util.*;
public class Main {
public static HashMap<String,Integer> map = new HashMap<String,Integer>(){{
put("A",1);
put("2",2);
put("3",3);
put("4",4);
put("5",5);
put("6",6);
put("7",7);
put("8",8);
put("9",9);
put("10",10);
put("J",11);
put("Q",12);
put("K",13);
}};
public static ArrayList<List<String>> res = new ArrayList<>();//数字的全排列
public static ArrayList<String> path = new ArrayList<>();
public static ArrayList<List<String>> resType = new ArrayList<>();//运算符号的全排列,4选3
public static ArrayList<String> pathType = new ArrayList<>();
public static String[] type = {"+","-","*","/"};//运算符号
public static boolean flag = false;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextLine()) { // 注意 while 处理多个 case
flag = false;
String[] game = in.nextLine().split("\\s");
boolean[] visited = new boolean[game.length];
if(containsJoker(game)){
System.out.println("ERROR");
}else{
Arrays.sort(game);
dfs(game,visited);
dfsType(type);
for(List<String> s1 : res){
for(List<String> s2 : resType){
if(cal(s1,s2) == 24){
StringBuilder sb = new StringBuilder();
for(int k=0;k<s1.size();k++){
sb.append(s1.get(k));
if(k<s2.size()){
sb.append(s2.get(k));
}
}
flag = true;//有解
System.out.println(sb.toString());//输出一种情况即可
break;
}
}
if(flag){//有解直接退出
break;
}
}
if(!flag){//无解
System.out.println("NONE");
}
}
}
}
public static boolean containsJoker(String[] game){
for(String s : game){
if(s.equals("JOKER") || s.equals("joker")){
return true;
}
}
return false;
}
//搜索所有数字的排列情况,剪枝去重
public static void dfs(String[] game,boolean[] visited){
//终止条件
if(path.size()==game.length){
res.add(new ArrayList<>(path));
return;
}
for(int i=0;i<game.length;i++){
if(i>0 && game[i] == game[i-1] && !visited[i-1]){
continue;
}
if(!visited[i]){
visited[i] = true;
path.add(game[i]);
dfs(game,visited);
path.remove(path.size()-1);//回溯
visited[i] = false;
}
}
}
//搜索所有运算符号的排列,4选3,允许重复
public static void dfsType(String[] type){
//终止条件
if(pathType.size()==3){
resType.add(new ArrayList<>(pathType));
return;
}
for(int i=0;i<type.length;i++){
pathType.add(type[i]);
dfsType(type);
pathType.remove(pathType.size()-1);//回溯
}
}
//计算一个算式的结果,根据题意按从左到右计算即可
public static int cal(List<String> listNum,List<String> listType){
int res = map.get(listNum.get(0));//初始化为第一个数
for(int i = 0;i<listType.size();i++){
switch(listType.get(i)){
case "+":
res += map.get(listNum.get(i+1));
break;
case "-":
res -= map.get(listNum.get(i+1));
break;
case "*":
res *= map.get(listNum.get(i+1));
break;
case "/":
res /= map.get(listNum.get(i+1));
break;
}
}
return res;
}
}