#include <bits/stdc++.h>
using namespace std;
char ord,last_ord;
int m,n,ans;
int I;
int Length(int x)
{
bool down_zero=0;
int i;
if(x<0)
{
x=-x;
down_zero=1;
}
for(i=1;true;i++)
{
if(x<=pow(10,i)) break;
}
if(down_zero) return i+1;
return i;
}
void Plus(int x,int y)
{
ans=x+y;
cout << x << "+" << y << "=" << ans << endl;
cout << Length(x)+Length(y)+Length(ans)+2 << endl;
last_ord=ord;
}
void Subtr(int x,int y)
{
ans=x-y;
cout << x << "-" << y << "=" << ans << endl;
cout << Length(x)+Length(y)+Length(ans)+2 << endl;
last_ord=ord;
}
void Multi(int x,int y)
{
ans=x*y;
cout << x << "*" << y << "=" << ans << endl;
cout << Length(x)+Length(y)+Length(ans)+2 << endl;
last_ord=ord;
}
int main()
{
cin >> I;
while(I--)
{
cin >> ord;
if(ord<='c'&&ord>='a')
{
cin >> m >> n;
if(ord=='a') Plus(m,n);
else if(ord=='b') Subtr(m,n);
else Multi(m,n);
}
else
{
cin >> m >> n;
m+=((int(ord)-48)*pow(10,Length(m)));
if(last_ord=='a') Plus(m,n);
else if(last_ord=='b') Subtr(m,n);
else Multi(m,n);
}
}
return 0;
}