from sys import stdin
n = int(stdin.readline().strip())
data = []
for i in range(n):
data.append(stdin.readline().strip())
def slove(string):
list1 = [' ','_','+','-','*','/','?',':',';','!']
letter = string[0]#預防第一個為'-'
for i in range(1,len(string)):
if string[i] in list1 or string[i].isalpha():#先把字母跟所有符號,包括['-', ' ']
letter += '*'
else:
letter += string[i] #如果有'**'(原來應該為'*-')在裡面,就用replace(before, after)
letter = letter.replace('**','*-')
print(eval(letter))#eval()可以直接在字串結構進行運算 for i in data: slove(i)
for i in data:
slove(i)