#include <iostream>
using namespace std;
int main() {
int n,i = 0;
cin >> n;
while(i < n){
int a;
long long int b,c;
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 if(a == 4){
cout << b / c << endl;
}
i++;
}
}