q=[*([:+,:-,:*]*3).combination(3)].uniq;while "0 0 0 0\n"!=s=gets;g=nil;s.split.permutation.map{|a,b,c,d,f|;q.map{|x,y,z|(10==eval(e="((%s%s%s)%s%s)%s%s"%[a,x,b,y,c,z,d]))&&($stderr<<e<<?\n;puts f=g=e;break)};break if f};p 0 if !g;end