import java.util.Scanner;
public class oq{
public static void main(String[]argv){
Scanner sc=new Scanner(System.in);
int time=sc.nextInt();
int time2;
int a;
long b,c;
while(sc.hasNext()){
for(int i=0;i<time;i++){
a=sc.nextInt();
b=sc.nextLong();
c=sc.nextLong();
switch(a){
case 1:
System.out.println(b+c);
break;
case 2:
System.out.println(b-c);
break;
case 3:
System.out.println(b*c);
break;
case 4:
System.out.println(b/c);
break;
}
}
}
}
}