#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char x,x1;
int cd(int s){
int sum=0;
if(s<0)sum++;
s=abs(s);
while(s>0){
s/=10;
sum++;
}
return sum;
}
int main(){
scanf("%d",&n);
while(n--){
cin>>x1;
if(x1=='a'||x1=='b'||x1=='c'){
scanf("%d%d",&a,&b);
x=x1;
}
else{
scanf("%d%d",&a,&b);
if(x1!='-')a+=pow(10,cd(a))*(int(x1)-'0');
else a=-a;
}
printf("%d",a);
if(x=='a')printf("+");
if(x=='b')printf("-");
if(x=='c')printf("*");
printf("%d",b);
if(x=='a')printf("=%d\n%d\n",a+b,2+cd(a)+cd(b)+cd(a+b));
if(x=='b')printf("=%d\n%d\n",a-b,2+cd(a)+cd(b)+cd(a-b));
if(x=='c')printf("=%d\n%d\n",a*b,2+cd(a)+cd(b)+cd(a*b));
}
return 0;
}