#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j;
long int N,a,b,c;
scanf("%ld",&N);
for(i=0;i<N;i++)
{
for(j=0;j<3;j++)
{
scanf("%ld %ld %ld",&a,&b,&c);
if(a==1)
printf("%ld\n",b+c);
else if(a==2)
printf("%ld\n",b-c);
else if(a==3)
printf("%ld\n",b*c);
else if(a==4)
printf("%ld\n",b/c);
}
}
return 0;
}