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