Go: package main

import (
	"bufio"
	"fmt"
	"go/token"
	"go/types"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		stdin.Scan()
		exp := strings.TrimRight(stdin.Text(), "=")
		res, _ := types.Eval(token.NewFileSet(), nil, token.NoPos, exp)
		fmt.Println(res.Value)
	}
}

Python: def ReversePolishNotation(string):

    priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2}

    stack = []
    signStack = ["Sentinel"]

    inputCountent = string[:-1]

    for item in string[:-1]:
        if item == "(":
            signStack.append(item)
        elif item == ")":
            while signStack[-1] != "(":
                stack.append(signStack.pop())
            signStack.pop()
        else:
            if item in priority.keys():
                if priority[signStack[-1]] < priority[item]:
                    signStack.append(item)
                else:
                    top = signStack.pop()
                    stack.append(top)
                    signStack.append(item)
            else:
                stack.append(item)

    while signStack[-1] != "Sentinel":
        stack.append(signStack.pop())

    return stack


def Calculate(formulaList):

    signs = ["+", "-", "*", "/"]

    stack = []

    for item in formulaList:

        if item not in signs:
            stack.append(item)
        else:
            num1 = int(stack.pop())
            num2 = int(stack.pop())

            if item == "+":
                result = num2 + num1
            elif item == "-":
                result = num2 - num1
            elif item == "*":
                result = num2 * num1
            elif item == "/":
                result = num2 / num1

            stack.append(result)

    return stack[0]


inputCount = int(input())

for lp in range(inputCount):
    formula = input()

    rpn = ReversePolishNotation(formula)
    result = Calculate(rpn)

    print(result)

Python: import sys
import re
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    for _ in range(int(sys.stdin.readline())):
        expr = sys.stdin.readline()[:-1].strip("=")
        expr = re.sub(".d+","",expr)
        print(eval(expr.replace("/","//")))
 
solve()

Python: def f1(line):
    p = None
    q = None
    for i, s in enumerate(line):
        if s == '(':
            p = i
        elif s == ')':
            q = i
        if q:
            break
    else:
        return f2(line)
    before = line[:p]
    after = line[q + 1:]
    x = f2(line[p + 1:q])
    return f1(before + str(x) + after)


def f2(f_line):
    foo = []
    digit = ''
    for x in f_line:
        if x.isdigit():
            digit += x
        else:
            foo.append(int(digit))
            foo.append(x)
            digit = ''
    foo.append(int(digit))
    return f3(foo, 'first')


def f3(foo, flg):
    if len(foo) == 1:
        return foo[0]
    target = None
    for i, fo in enumerate(foo):
        if flg == 'first':
            target = f4(foo, fo, i)
        elif flg == 'second':
            target = f5(foo, fo, i)
        if target:
            break
    else:
        flg = 'second'
        return f3(foo, flg)
    foo = foo[:i-1] + [target] + foo[i+2:]
    return f3(foo, flg)


def f4(foo, fo, i):
    target = None
    if fo == '*':
        target = foo[i-1] * foo[i+1]
    elif fo == '/':
        target = int(foo[i-1] / foo[i+1])
    return target


def f5(foo, fo, i):
    target = None
    if fo == '+':
        target = foo[i-1] + foo[i+1]
    elif fo == '-':
        target = int(foo[i-1] - foo[i+1])
    return target


for _ in range(int(input())):
    input_line = input()
    ans = f1(input_line[:-1])
    print(ans)

Python: for _ in[0]*int(input()):print(int(eval(input()[:-1])))

Python: # ????????±?????¬??§??????????????????[l, r)??§??????
def getLR(li):
    l, r = 0, 0
    for i in range(len(li)):
        if li[i] == "(":
            l = i
        if li[i] == ")":
            r = i + 1
            return l, r
    return l, r

# li????¨?????????????????????????(li?????¬??§???????????????)
def calc(li):
    # *, / ?????????
    t_li = []
    while True:
        for i in range(len(li) - 2):
            if li[i + 1] == "*":
                t_li = li[:i] + [li[i] * li[i + 2]] + li[i + 3:]
                li = list(t_li)
                break
            elif li[i + 1] == "/":
                t_li = li[:i] + [li[i] // li[i + 2]] + li[i + 3:]
                li = list(t_li)
                break
        else:
            # ??´??°??????????????°????????????????????????
            break

    # +, - ?????????
    while True:
        for i in range(len(li) - 2):
            if li[i + 1] == "+":
                t_li = li[:i] + [li[i] + li[i + 2]] + li[i + 3:]
                li = list(t_li)
                break
            elif li[i + 1] == "-":
                t_li = li[:i] + [li[i] - li[i + 2]] + li[i + 3:]
                li = list(t_li)
                break
        else:
            # ??´??°??????????????°????????????????????????
            break

    return t_li


n = int(input())
for _ in range(n):
    s = input()[:-1]

    # ??°?????¨?¨????????????????????????? ("#"?????????)
    s = "#(" + s + ")#"
    li = []
    number = ""
    for i in range(len(s)):
        if s[i].isdigit():
            number += s[i]
        else:
            if number != "":
                li.append(int(number))
                number = ""
            li.append(s[i])

    # ??¬??§??????????????±?????¨??????????????????????????????
    while True:
        # print(li)
        l, r = getLR(li)

        # ??¬??§????????????????????°??????
        if r == 0:
            break

        li = li[:l] + calc(li[l + 1 : r - 1]) + li[r:]

    print(li[1])

Python: n=int(input())
for i in range(n):
	a=input()
	b=""
	for i in a:
		b+=i
		if i=='/':b+='/'
	print(int(eval(a[:len(a)-1])))

Python: n=int(input())
s=""
for i in range(n):
    s=input()
    print(eval(s[0:-1]))

Python: for _ in range(int(input())):
    ans = eval(input().replace('/', '//')[:-1])
    print(str(ans))

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp
"""
import sys
import re


def solve(exp):
    exp = exp.replace('=', '')
    exp = exp.replace('/', '//')
    return eval(exp)


def solve2(exp):
    exp = exp.replace('=', '')
    p = re.compile('(\d)/(\d)')
    return eval((p.sub(r'int(\1/\2)', exp)))


def main(args):
    n = int(input())
    for _ in range(n):
        expression = input().strip()
        result = solve2(expression)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])