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: print(*[eval(input()[:-1].replace("/", "//")) for _ in range(int(input()))], sep="\n")

Python: #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    n = int(readline())
    for _ in range(n):
        print(eval(readline().replace('/', '//').replace('=', '')))
    exit()


if __name__ == '__main__':
    main()

Python: n = int(input())
for i in range(n):
    s = raw_input().split('=')
    print(eval(s[0]))

Python: from collections import deque
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(repr(item))
        stderr.write(sep)
    stderr.write(end)



def eva(l, r, op):
    if op == "+":
        return l + r
    elif op == "-":
        return l - r
    elif op == "*":
        return l * r
    elif op == "/":
        return l // r


def calc(exp):
    debug(exp)
    i = 0
    num = deque()
    ops = deque()
    ope = ""
    while i < len(exp):
        if exp[i] == '(':
            end = 1
            s = 1
            while True:
                if exp[i+end] == "(":
                    s += 1
                elif exp[i+end] == ")":
                    s -= 1
                if s == 0:
                    break
                end += 1
            num.append(calc(exp[i+1:i+end]))
            i += end
            if ope:
                l = num.pop()
                r = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        elif exp[i] in ["*", "/"]:
            ope = exp[i]
        elif exp[i] in ["+", "-"]:
            ops.append(exp[i])
        elif exp[i] == "=":
            pass
        else:
            temp = ""
            j = 0
            while i + j < len(exp) and exp[i+j].isnumeric():
                temp += exp[i+j]
                j += 1
            num.append(int(temp))
            i += j - 1
            if ope:
                num.append(eva(num.pop(), num.pop(), ope))
                ope = ""
        i += 1
    while len(ops) != 0:
        l = num.popleft()
        r = num.popleft()
        num.appendleft(eva(l,r,ops.popleft()))
    
    return num[0]


n = int(input())
for i in range(n):
    exp = input()
    print(calc(exp))

Python: from collections import deque

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

n = int(input())
for i in range(n):
    s = input()
    out = []
    ope = deque([])
    for j in range(len(s)):
        inp = s[j]
        if inp == "=":
            while len(ope):
                out.append(ope.pop())
            break
        elif inp.isdecimal():
            if len(out) and s[j - 1].isdecimal():
                tmp = out.pop()
                out.append(tmp*10 + int(inp))
            else:
                out.append(int(inp))
        elif inp == "(":
            ope.append(inp)
        elif inp == ")":
            while True:
                tmp = ope.pop()
                if tmp == "(":
                    break
                out.append(tmp)
        elif priority[inp] == 1:
            while len(ope) and priority[ope[-1]] >= 1:
                tmp = ope.pop()
                out.append(tmp)
            else:
                ope.append(inp)
        elif priority[inp] == 0:
            while len(ope) and priority[ope[-1]] >= 0:
                tmp = ope.pop()
                out.append(tmp)
            else:
                ope.append(inp)
    ans = deque([])
    for k in range(len(out)):
        if out[k] == "+":
            a = ans.pop()
            ans[-1] += a
        elif out[k] == "-":
            a = ans.pop()
            ans[-1] -= a
        elif out[k] == "*":
            a = ans.pop()
            ans[-1] *= a
        elif out[k] == "/":
            a = ans.pop()
            b = ans.pop()
            ans.append(int(b/a))
        else:
            ans.append(out[k])
    print(ans[0])

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())):
    ans = f1(input())
    print(ans)

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

Python: r=[eval(input()[:-1].replace("/","//")) for i in range(int(input()))]
[print(i) for i in r]

Python: from collections import deque
from sys import stderr

def eva(l, r, op):
    if op == "+":
        return l + r
    elif op == "-":
        return l - r
    elif op == "*":
        return l * r
    elif op == "/":
        return l // r


def calc(exp):
    i = 0
    num = deque()
    ops = deque()
    ope = ""
    while i < len(exp):
        if exp[i] == '(':
            end = 1
            s = 1
            while True:
                if exp[i+end] == "(":
                    s += 1
                elif exp[i+end] == ")":
                    s -= 1
                if s == 0:
                    break
                end += 1
            num.append(calc(exp[i+1:i+end]))
            i += end
            if ope:
                l = num.pop()
                r = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        if exp[i] in ["*", "/"]:
            ope = exp[i]
        elif exp[i] in ["+", "-"]:
            ops.append(exp[i])
        elif exp[i] == "=":
            pass
        else:
            temp = ""
            j = 0
            while i + j < len(exp) and exp[i+j].isnumeric():
                temp += exp[i+j]
                j += 1
            num.append(int(temp))
            i += j - 1
            if ope:
                num.append(eva(num.pop(), num.pop(), ope))
                ope = ""
        i += 1
    while len(ops) != 0:
        l = num.popleft()
        r = num.popleft()
        num.appendleft(eva(l,r,ops.popleft()))

    
    return num[0]


n = int(input())
for i in range(n):
    exp = input()
    print(calc(exp))