#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
long long int n,a,b,c,i;
cin>>n;
for(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;} }
//system("pause");
return 0;
}