#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[99],b[99],c[99],N,i;
while(scanf("%d",&N)!=EOF){
for(i=1;i<=N;i++){
scanf("%d%d%d",&a[i-1],&b[i-1],&c[i-1]);
if(a[i-1]==1){
printf("%d\n",b[i-1]+c[i-1]);
}
if(a[i-1]==2){
printf("%d\n",b[i-1]-c[i-1]);
}
if(a[i-1]==3){
printf("%d\n",b[i-1]*c[i-1]);
}
if(a[i-1]==4){
printf("%d\n",b[i-1]/c[i-1]);
}
}
}
return 0;
}