#include <bits/stdc++.h>
using namespace std;
int a, b, c, tot;
char d, e;
int main()
{
int t;
scanf("%d", &t) ;
while (t --)
{
scanf("%d %c %d %c %d", &a, &d, &b, &e, &c) ;
if ((d == '+' || d == '-') && (e == '*' || e == '/' || e == '%'))
{
if (e == '*')
{
tot = b * c ;
}
else if (e == '/')
{
tot = b / c ;
}
else if (e == '%')
{
tot = b % c ;
}
if (d == '+')
{
tot = a + tot ;
}
else if (d == '-')
{
tot = a - tot ;
}
}
else
{
if (d == '+')
{
tot = a + b ;
}
else if (d == '-')
{
tot = a - b ;
}
else if (d == '*')
{
tot = a * b ;
}
else if (d == '/')
{
tot = a / b ;
}
else if (d == '%')
{
tot = a % b ;
}
if (e == '+')
{
tot += c ;
}
else if (e == '-')
{
tot -= c ;
}
else if (e == '*')
{
tot *= c ;
}
else if (e == '/')
{
tot /= c ;
}
else if (e == '%')
{
tot %= c ;
}
}
printf("%d\n", tot) ;
}
return 0;
}