#include<bits/stdc++.h>
#define ywj(a) freopen(#a".in","r",stdin);
#define wlp ios::sync_with_stdio(false);
#define f1(i,a,b) for(register int i=a;i<=b;i++)
#define f2(i,a,b) for(register int i=a;i>=b;i--)
#define ll long long
#define maxn 1005
using namespace std;
int ans;
string s;
int wot(string x){
bool vis=true;
if(x[0]=='-') vis=false;
else if(x[0]=='+') vis=true;
unsigned short len=x.length();
int num=0;
ll xp=1;
f2(i,len-1,0){
if(x[i]=='-'||x[i]=='+') continue;
num+=(x[i]-'0')*xp;
xp*=10;
}
if(vis) return num;
else return 0-num;
}
int work(int x){
int point=0;
if(x<0) point++;
while(x!=0){
point++;
x/=10;
}
return point;
}
int read(){
int x=0,f=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}
void write(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int main(){
wlp;
int T;
char last_op;
T=read();
while(T--){
ans=2;
int point=0;
int a,b,c;
getline(cin,s);
int len=s.length();
if(!isdigit(s[0])){
if(s[0]=='a') last_op='+';
else if(s[0]=='b') last_op='-';
else if(s[0]=='c') last_op='*';
}
string tmp;
tmp.clear();
f1(i,2,len-1){
if(!isdigit(s[i])){point=i;break;}
tmp+=s[i];
}
a=wot(tmp);ans+=work(a);
tmp.clear();
f1(i,point+1,len-1){
if(!isdigit(s[i])) break;
tmp+=s[i];
}
b=wot(tmp);ans+=work(b);
if(last_op=='+') c=(a+b);
else if(last_op=='-') c=(a-b);
else if(last_op=='*') c=(a*b);
ans+=work(c);
write(a);putchar(last_op);write(b);putchar('=');write(c);puts("");
write(ans);
puts("");
}
return 0;
}