#include<bits/stdc++.h>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef long long ll;


int lp;
int lpcnt = 0;


string str;

bool input(){

  if(lpcnt==0)cin>>lp;

  if(lpcnt==lp)return false;
  cin>>str;

  lpcnt++;
  return true;
}


class S{
public:
  bool isnum;
  bool isc;
  char c;
  int num;
  S(bool isnum, bool isc, char c, int num):isnum(isnum),isc(isc),c(c),num(num){}
  S(){isnum=isc=false; c='#'; num=0;}
  void print(){
    printf("%d %d %d %c\n",isnum,isc,num,c);
  }
};

typedef pair<int,string> pis;
typedef pair<char,string> pcs;

bool isnum(char c){
  return '0'<=c && c<='9';
}

int ctonum(char c){
  return c-'0';
}

pis getHeadNum(string str){

  pis ret = pis(0,"");
  int st = 0;
  while(str.size()!=st && isnum(str[st])){
    ret.first *= 10;
    ret.first += ctonum(str[st]);
    st++;
  }

  ret.second = str.substr(st);
  return ret;
}

pcs getHeadChar(string str){
  return pcs(str[0], str.substr(1));
}

bool iscalc(char c){
  if(c=='*' || c=='+' || c=='-' || c=='/')return true;
  return false;
}


vector<S> getEq(string str){
  vector<S> eq;
  string sc = str;
  eq.clear();

  while(sc.size()!=0){
    int hu = 1;
    S add;
    if(sc[0]=='-' && ((eq.size()!=0 && iscalc(eq[eq.size()-1].c))||eq.size()==0)){
      hu = -1;
      sc = sc.substr(1);
    }
    if(isnum(sc[0])){
      add.isnum = true;
      pis res = getHeadNum(sc);
      add.num = hu*res.first;
      sc = res.second;
    }else{
      add.isc = true;
      pcs res = getHeadChar(sc);
      add.c = res.first;
      sc = res.second;
    }
    eq.push_back(add);
  }
  return eq;
}

int calc(int st, int en, vector<S>& eq){
  
  /*
  
  for(int i=st;i<en;i++){
    eq[i].print();
  }puts("");
  */



  if(st>=en){
    printf("%d %d\n",st,en);
    assert(0);
  }

  int num = eq[st].num;
  if(st+1==en)return num;
  int a=0;

  reps(i,st,en){

    if(eq[i].c=='(')a++;
    if(eq[i].c==')')a--;


    if(a==0){
      if(eq[i].c=='-'){
	return calc(st, i, eq) - calc(i+1, en, eq);
      }
      if(eq[i].c=='+'){
	return calc(st, i, eq) + calc(i+1, en, eq);
      }
    }

  }

  a=0;

  reps(i,st, en){

    if(eq[i].c=='(')a++;
    if(eq[i].c==')')a--;
    if(a==0){
      if(eq[i].c=='*'){
	return calc(st, i, eq) * calc(i+1, en, eq);
      }
      if(eq[i].c=='/'){
	return calc(st, i, eq) / calc(i+1, en, eq);
      }
    }

  }

  if(eq[st].c=='('){
    return calc(st+1, en-1, eq);
  }
  puts("AAA");
  assert(0);
  return -1;
  
}
int solve(){
  vector<S> eq = getEq(str);
  return calc(0,eq.size()-1, eq);
}

int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}