#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#include<set>
#define ll long long
using namespace std;
const int N = 1010;
const int inf = 0x3f3f3f3f;
#define PI 3.141592653589
#define fr(i,r,l) for(int i=r;i<l;i++)
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, c, ans;
char d, e;
scanf("%d %c %d %c %d", &a, &d, &b, &e, &c);
if ((d == '+' || d == '-') && (e == '*' || e == '/' || e == '%')) {
if (e == '*') {
ans = b * c;
} else if (e == '/') {
ans = b / c;
} else if (e == '%') {
ans = b % c;
}
if (d == '+') {
ans = a + ans;
} else if (d == '-') {
ans = a - ans;
}
} else {
if (d == '+') {
ans = a + b;
} else if (d == '-') {
ans = a - b;
} else if (d == '*') {
ans = a * b;
} else if (d == '/') {
ans = a / b;
} else if (d == '%') {
ans = a % b;
}
if (e == '+') {
ans += c;
} else if (e == '-') {
ans -= c;
} else if (e == '*') {
ans *= c;
} else if (e == '/') {
ans /= c;
} else if (e == '%') {
ans %= c;
}
}
printf("%d\n", ans);
}
return 0;
}