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