# swea 1223 '계산기2'(전용)
def parse_notation(string):
op_rank = {
'+': 1,
'*': 2
}
result = ''
stk = []
for c in string:
if c.isdigit():
result += c
continue
if len(stk) == 0:
stk.append(c)
continue
while len(stk) and op_rank[stk[-1]] >= op_rank[c]:
result += stk.pop()
stk.append(c)
while len(stk):
result += stk.pop()
return result
def calculate(string):
stk = []
for c in string:
if c.isdigit():
stk.append(int(c))
continue
num1 = stk.pop()
num2 = stk.pop()
if c == '+':
stk.append(num1 + num2)
else:
stk.append(num1 * num2)
return stk.pop()
if __name__ == '__main__':
T = 10
for t in range(1, T+1):
length = int(input())
string = input()
parsed_string = parse_notation(string)
result = calculate(parsed_string)
print('#{} {}'.format(t, result))