#include <iostream>
using namespace std;
int main()
{
signed long long a,b,c,N,i;
cin >>N;
signed long long A[N];//還用了陣列
for (i=0;i<N;i++){
cin >>a>>b>>c;
switch (a) {
case 1 :
A[i] = b+c;
break;
case 2 :
A[i] = b-c;
break;
case 3 :
A[i] = b*c;
break;
case 4 :
A[i] = b/c;
break;
}
}
for (i=0;i<N;i++){
cout <<A[i]<<endl;
}
}