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
import java.lang.*;
import java.util.*;

class Now {
	private static Now singleton = null;
	private static int id;
	private static String exp;

	private Now() {
		id = 0;
	}

	private Now(String exp) {
		this.exp = exp;
		id = 0;
	}

	public static synchronized void initialize(String exp) {
		singleton = new Now(exp);
	}

	public static synchronized Now getInstance() {
		if(singleton == null){
			singleton = new Now();
		}
		return singleton;
	}

	public static int getId() {
		return id;
	}

	public static String getExp() {
		return exp;
	}

	public static int plusId() {
		id++;
		return id;
	}
}


interface Parser {
	public int parse();
}

class Expression implements Parser{

	public int parse(){
		int res = new Term().parse();

		while(true){
			char now = Now.getExp().charAt(Now.getId());
			
			if(now == '+') {
				Now.plusId();
				res += new Term().parse();
			}
			else if(now == '-') {
				Now.plusId();
				res -= new Term().parse();
			}
			else {
				break;
			}
		}

		return res;
	}
}

class Term implements Parser {

	public int parse(){
		int res = new Factor().parse();
		while(true) {
			char now = Now.getExp().charAt(Now.getId());

			if(now == '*') {
				Now.plusId();
				res *= new Factor().parse();
			}
			else if(now == '/') {
				Now.plusId();
				res /= new Factor().parse();
			}
			else {
				break;
			}
		}

		return res;
	}
}

class Factor implements Parser {

	public int parse() {
		int res=0;
		char now = Now.getExp().charAt(Now.getId());

		if(now == '(') {
			Now.plusId();
			res = new Expression().parse();
			Now.plusId();
		}
		else {
			return new Number().parse();
		}

		return res;
	}
}

class Number implements Parser {

	public int parse() {
		int res = 0;
		String exp = Now.getExp();

		while(true) {
			char now = exp.charAt(Now.getId());
			if(!Character.isDigit(now))break;

			res *= 10;
			res += Character.digit(now,10);
			
			Now.plusId();
		}

		return res;
	}
}

public class Main {

	public void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String exp;
		exp = sc.nextLine();

		for(int i=0;i<n;i++) {
			exp = sc.nextLine();
			Now.initialize(exp);
			System.out.println(new Expression().parse());	
		}
	}

	public static void main(String[] args) {
		Main problem_0109 = new Main();
		problem_0109.solve();
	}
}