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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	
	String formulaStr = ""; //式を保存する文字列
	int index = 0; //式の文字列のインデックス
	
	public static void main(String[] args) {
		Main main = new Main();
		main.smartCalculator();
		return;
	}
	
	//四則演算を計算する
	private void smartCalculator() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			String inputNumStr = bufferedReader.readLine();
			int inputNum = Integer.parseInt(inputNumStr); //与えられる式の数
			
			//式の計算
			for (int i = 0; i < inputNum; i++) {
				formulaStr = bufferedReader.readLine();
				index = 0;
				System.out.println(this.calculationFormula());
			}
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
	
	//式の計算を行う
	private Long calculationFormula() {
		
		long answer = 0;
		
		answer = this.calculationAddSub();
		
		return answer;
	}
	
	//足し算、引き算の処理
	private Long calculationAddSub() {
		
		long answer = this.calculationMulDiv();
		
		while (true) {
			
			switch (formulaStr.charAt(index)) {
				case '+':
					index++;
					answer += this.calculationMulDiv();
					break;
				case '-':
					index++;
					answer -= this.calculationMulDiv();
					break;
				default:
					return answer;
			}
			
		}
	}
	
	//掛け算、割り算の処理
	private Long calculationMulDiv() {
		
		long answer = this.calculationTerm();
		
		while (true) {
			
			switch (formulaStr.charAt(index)) {
				case '*':
					index++;
					answer *= this.calculationTerm();
					break;
				case '/':
					index++;
					answer /= this.calculationTerm();
					break;
				default:
					return answer;
			}
			
		}
	}
	
	//括弧と数字の処理
	private Long calculationTerm() {
		
		long answer = 0;
		
		//括弧があった場合、優先して処理する
		if (formulaStr.charAt(index) == '(') {
			index++;
			answer = this.calculationAddSub();
			index++;
			return answer;
		}
		
		//数字の場合の処理
		if (Character.isDigit(formulaStr.charAt(index))) {
			return this.calculationValue();
		}
		
		return (long) 0;
	}
	
	//文字列から非演算子の数字のみを切り出す
	private Long calculationValue() {
		
		String tmpStr = formulaStr.substring(index); //処理が終わる前の式を切り出す
		String[] tmpStrs = tmpStr.split("[+-/\\*=)]");
		
		index += tmpStrs[0].length(); //インデックスの更新
		
		return Long.parseLong(tmpStrs[0]);
		
	}
}