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



Input

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.

Output

For each datasets, prints the result of calculation.

Example

Input

2
4-2*3=
4*(8+4+3)=


Output

-2
60
#include <bits/stdc++.h>
#define int long long
using namespace std;

// exp1 = exp2 [ ('+'|'-') exp2 ]*
// exp2 = exp3 [ ('*'|'/') exp3 ]*
// exp3 = '(' exp1 ')' | number
int exp1(const string& s, int& i);
int exp2(const string& s, int& i);
int exp3(const string& s, int& i);
int number(const string& s, int& i);
int exp1(const string& s, int& i) {
  int acc = exp2(s, i);
  while (1) {
    if (s[i] == '+') acc += exp2(s, ++i);
    else if (s[i] == '-') acc -= exp2(s, ++i);
    else return acc;
  }
}
int exp2(const string& s, int& i) {
  int acc = exp3(s, i);
  while (1) {
    if (s[i] == '*') acc *= exp3(s, ++i);
    else if (s[i] == '/') acc /= exp3(s, ++i);
    else return acc;
  }
}
int exp3(const string& s, int& i) {
  if (s[i] == '(') {
    int ret = exp1(s, ++i);
    assert(s[i] == ')');
    i++;
    return ret;
  }
  return number(s, i);
}
int number(const string& s, int& i) {
  int acc = 0;
  while (isdigit(s[i])) {
    acc = acc * 10 + (s[i++] - '0');
  }
  return acc;
}

void solve() {
  string s; cin >> s;
  int i = 0;
  cout << exp1(s, i) << endl;
  assert(s[i] == '=');
}
signed main() {
  int T; cin >> T;
  while (T--) solve();
}

