//============================================================================
// Name        : aoj0041.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#define MAX_NUM 4

const char mark[MAX_NUM] = "+-*";
int val[MAX_NUM];
int end;
char ans[4096];

int calculateRP(char *str){
    int stack[MAX_NUM], sp = 0;
    char *cp;
    for(cp = str;*cp != '\0';cp++){
    	if(isalpha(*cp)){
            stack[sp++] = val[*cp - 'a'];
        }else if(*cp == '+'){
        	stack[sp - 2] += stack[sp - 1];
        	sp--;
        }else if(*cp == '-'){
        	stack[sp - 2] -= stack[sp - 1];
        	sp--;
        }else if(*cp == '*'){
            stack[sp - 2] *= stack[sp - 1];
            sp--;
        }
    }
    return stack[0];
}

void createNormalFormula(char *hp,char *rhp){
	char *cp, *rcp;
	for(cp = hp,rcp = rhp;*cp != '\0';cp++){
		*rcp = '\0';
		if(isalpha(*cp) || *cp == ' '){
			*rcp = *cp;
			rcp++;
		}else{
			int flag = 0;
			char *rtmp, *ltmp, *tmp;
			for(rtmp = rcp - 1;;rtmp--){
				if(*rtmp == '('){
					flag--;
				}else if(*rtmp == ')'){
					flag++;
				}
				if(flag == 0 && (*rtmp == '(' || isalpha(*rtmp))){
					break;
				}
			}
			for(ltmp = rtmp - 1;;ltmp--){
				if(*ltmp == '('){
					flag--;
				}else if(*ltmp == ')'){
					flag++;
				}
				if(flag == 0 && (*ltmp == '(' || isalpha(*ltmp))){
					break;
				}
			}
			for(tmp = rcp;tmp > ltmp;tmp--){
				*tmp = *(tmp - 1);
			}
			*ltmp = '(';
			*rcp = ')';
			rcp++;
			rtmp++;
			for(tmp = rcp;tmp > rtmp;tmp--){
				*(tmp + 1) = *(tmp - 1);
			}
			*rtmp = *cp;
			*(rtmp + 1) = ' ';
			rcp += 2;
		}
	}
	*rcp = '\0';
}

void createRPFormula(int vn,int mn,char *hp,char *cp){
    int i;
    static int flag[MAX_NUM] = {0};
    if(vn - 1 == mn && vn == MAX_NUM){
        *(cp - 1) = '\0';
        if(calculateRP(hp) == 10){
        	 char str[4096] = "";
        	 createNormalFormula(hp,str);
        	 strcpy(ans,str);
        	 end = 1;
        	 return;
        }

    }
    if(vn - mn > 1){
        for(i = 0;i < 3;i++){
            *cp = mark[i];
            *(cp + 1) = ' ';
             createRPFormula(vn,mn + 1,hp,cp + 2);
             if(end){
            	 return;
             }
        }
    }
    for(i = 0;i < MAX_NUM;i++){
        if(flag[i] == 0){
            flag[i] = 1;
            *cp = 'a' + i;
            *(cp + 1) = ' ';
             createRPFormula(vn + 1,mn,hp,cp + 2);
            flag[i] = 0;
            if(end){
            	return;
            }
        }
    }
}



int main(void){
    int i;
    char str[4096];
    while(1){
    	for(i = 0;i < MAX_NUM;i++){
    		scanf("%d",&val[i]);
    	}
    	for(i = 0;i < MAX_NUM;i++){
    		if(val[i] != 0){
    			break;
    		}
    	}
    	if(i == MAX_NUM){
    		break;
    	}
    	end = 0;
    	strcpy(ans,"0");
    	createRPFormula(0,0,str,str);
    	for(i = 0;i < strlen(ans);i++){
    		if(isalpha(ans[i])){
    			printf("%d",val[ans[i] - 'a']);
    		}else{
    			printf("%c",ans[i]);
    		}
    	}
    	printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1084