#include <iostream>
#include <stdio.h>
#include <vector>
int NUM=17;
using namespace std;
const int arr[3][3]={{10,5,8},{10,7,11},{9,3,11}};
int used[3][3]={{0,0,0},{0,0,0},{0,0,0}};
void testdiv(int a, int b, int c){//tests all possible division options
if( a+ b +c ==NUM) printf("%d:%d+%d+%d\n" ,NUM,a,b,c);
if( (a+ b)/c ==NUM&&(a+ b)%c==0) printf("%d:(%d+%d)/%d\n",NUM,a,b,c);
if( a/ b +c ==NUM&& a%b==0) printf("%d:%d/%d+%d\n" ,NUM,a,b,c);
if((b+c)&&a/(b+c)==NUM&& a%(b+c)==0)printf("%d:%d/(%d+%d)\n",NUM,a,b,c);
if( a+ b /c ==NUM&& b%c==0) printf("%d:%d+%d/%d\n" ,NUM,a,b,c);
}
void testmul(int a, int b, int c){//tests all possible options involving multiplication
if(a*b+c ==NUM) printf("%d:%d*%d+%d\n" ,NUM,a,b,c);
if((a*b)/c ==NUM&&(a*b)%c ==0) printf("%d:(%d*%d)/%d\n" ,NUM,a,b,c);
if(a+b*c ==NUM&&b%c ==0) printf("%d:%d+%d*%d\n" ,NUM,a,b,c);
if(a/b*c ==NUM&&a%b ==0) printf("%d:%d/%d*%d\n" ,NUM,a,b,c);
if(a/(b*c) ==NUM&&a%(b*c) ==0) printf("%d:%d/(%d*%d)\n" ,NUM,a,b,c);
}
void testdm(int a, int b, int c){//tests all possible division/multiplication/addition options
testdiv(a,b,c);
testmul(a,b,c);
}
void test(vector<int>& str){//generates all possible negative/positive combinations
testdm(+str[0],+str[1],+str[2]);
testdm(+str[0],+str[1],-str[2]);
testdm(+str[0],-str[1],+str[2]);
testdm(+str[0],-str[1],-str[2]);
testdm(-str[0],+str[1],+str[2]);
testdm(-str[0],+str[1],-str[2]);
testdm(-str[0],-str[1],+str[2]);
testdm(-str[0],-str[1],-str[2]);
}
void gensubstr(int x, int y,int depth, vector<int> str){//generates 3-substrings
int i,j;
used[x][y]=1;
str.push_back(arr[x][y]);
if(depth==3){
test(str);
used[x][y]=0;
return;
}
for(i=-1;i<=1;i+=2){
if(x+i>=3 || x+i<0) continue;
if(used[x+i][y]) continue;
gensubstr(x+i,y,depth+1,str);
}
for(i=-1;i<=1;i+=2){
if(y+i>=3 || y+i<0) continue;
if(used[x][y+i]) continue;
gensubstr(x,y+i,depth+1,str);
}
used[x][y]=0;
}
int main(){
vector<int> str;
for(NUM=7;NUM<=18;++NUM)
for(int i=0;i<3;++i)
for(int j=0;j<3;++j)
gensubstr(i,j,1,str);
return 0;
}