//a244: 新手訓練 ~ for + if
#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
for(int i=1; n>=i; i++){
int a, b, c;
cin >> a >> b >> c;
if(1 <= a <= 4){
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;
}