public class a12 {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int n=scanner.nextInt();
for(int i=0;i<n;i++) {
int a=scanner.nextInt();
long b=scanner.nextLong();
long c=scanner.nextLong();
if( 1 <= b && c <= 2147483647 ) {
if(a==1) {
System.out.println(b+c);
}
else if(a==2) {
System.out.println(b-c);
}
else if(a==3) {
System.out.println(b*c);
}
else if(a==4) {
System.out.println(b/c);
}
}
}
}
}