#38283: __py


11035093@mail.hpsh.tp.edu.tw (ಥ⁠‿⁠ಥ)


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