a=int(input())
for b in range(a):
c,d,e=input().split()
if int(c)==1:
print(int(d)+int(e))
elif int(c)==2:
print(int(d)-int(e))
elif int(c)==3:
print(int(d)*int(e))
else:
print(int(int(d)/int(e)))
0.0