#include<iostream>
/*
4
1 2 3
2 2 3
3 2 3
4 2 3
*/
using namespace std;
int main(){
long long n,a,b,c;
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a>>b>>c;
switch (a) {
case 1:
cout<<b+c<<endl;
break;
case 2:
cout<<b-c<<endl;
break;
case 3:
cout<<b*c<<endl;
break;
case 4:
cout<<b/c<<endl;
break;
}
}
}
return 0;
}