output_description: For each datasets, prints the result of calculation.
input_description: The input is a sequence of datasets. The first line contains an integer _n_
  which represents the number of datasets. There will be _n_ lines where each
  line contains an expression.
attempt: import sys
  
  # from me.io import dup_file_stdin
  
  
  def prec(op):
      if op in "+-":
          return 1
      if op in "*/":
          return 2
      raise NotImplementedError()
  
  
  def postFix(expr):
      stack = []
      operators = []
      num = 0
      isdigit = False
      for ch in expr:
          if ch.isdigit():
              isdigit = True
              num *= 10
              num += int(ch)
              continue
          else:
              if isdigit:
                  stack.append(num)
                  num = 0
              isdigit = False
  
              if ch == ")":
                  while len(operators) > 0:
                      op = operators.pop()
                      if op == "(":
                          break
                      else:
                          stack.append(op)
                  else:
                      raise ValueError
              elif ch == "(":
                  operators.append(ch)
              else:
                  while (
                      len(operators) > 0
                      and operators[-1] != "("
                      and prec(operators[-1]) >= prec(ch)
                  ):
                      stack.append(operators.pop())
                  operators.append(ch)
      if isdigit:
          stack.append(num)
      for op in operators[::-1]:
          if op not in "()":
              stack.append(op)
      return stack
  
  
  def evaluate(stack):
      op = stack.pop()
      if type(op) is int:
          return op
      else:
          b = evaluate(stack)
          a = evaluate(stack)
          return int(eval(str(a) + op + str(b)))
  
  
  # @dup_file_stdin
  def solve():
      for _ in range(int(sys.stdin.readline())):
          expr = sys.stdin.readline()[:-1].strip("=")
          print(evaluate(postFix(expr)))
  
  
  solve()
  
problem_description: Smart Calculator
  
  Your task is to write a program which reads an expression and evaluates it.
  
    * The expression consists of numerical values, operators and parentheses, and the ends with '='.
    * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.
    * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. 
    * You may assume that there is no division by zero.
    * All calculation is performed as integers, and after the decimal point should be truncated
    * Length of the expression will not exceed 100.
    * -1 × 109 ≤ intermediate results of computation ≤ 109
samples: [{"input": "4-2*3=\n    4*(8+4+3)=", "output": "-2\n    60"}]