#include <bits/stdc++.h>
using namespace std;
int n;
char bi[100][15];
int main()
{
cin >> n;
cin.get();
for (int i = 0; i < n; ++i)
cin.getline(bi[i], 15);
char pre;
for (int i = 0; i < n; ++i)
{
int num1 = 0, num2 = 0;
int tol = 0;
bool flag1 = false;
int length1 = 0, length2 = 0, length3 = 0;
if (bi[i][0] >= 'a' && bi[i][0] <= 'c')
{
pre = bi[i][0];
int length = 2;
while (bi[i][length])
{
if (bi[i][length] == ' ')
{
flag1 = true;
length++;
}
if (!flag1)
{
num1 = num1 * 10 + (bi[i][length] - 48);
length1++; length++;
}
else
{
num2 = num2 * 10 + (bi[i][length] - 48);
length2++; length++;
}
}
}
else
{
int length = 0;
while (bi[i][length])
{
if (bi[i][length] == ' ')
{
flag1 = true;
length++;
}
if (!flag1)
{
num1 = num1 * 10 + (bi[i][length] - 48);
length1++; length++;
}
else
{
num2 = num2 * 10 + (bi[i][length] - 48);
length2++; length++;
}
}
}
if (pre == 'a')
{
tol = num1 + num2;
cout << num1 << '+' << num2 << '=' << num1 + num2 << endl;
}
else if (pre == 'b')
{
tol = num1 - num2;
cout << num1 << '-' << num2 << '=' << num1 - num2 << endl;
}
else
{
tol = num1 * num2;
cout << num1 << '*' << num2 << '=' << num1 * num2 << endl;
}
bool flag2 = false;
if (tol < 0)
flag2 = true;
while (tol)
{
length3++;
tol /= 10;
}
int ans = length1 + length2 + length3 + 2;
flag2 ? cout << ans + 1 << endl : cout << ans << endl;
}
return 0;
}