#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
int main()
{
int x;
while (cin >> x)
{
for (int i = 0; i < x; i++)
{
int y;
long long a, b, c;
cin >> a >> b >> c;
long long res;
if (a == 1)
{
res = b + c;
}
else if (a == 2)
{
res = b - c;
}
else if (a == 3)
{
res = b * c;
}
else
{
res = b / c;
}
cout << res << endl;
}
}
}