#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector> 
#include <cstring>
#include <stack>
#include <iostream>
using namespace std;

//¶ñÌ¡»
void strcpy(char*a,char*b){
	while(*a++=*b++);
}

//¶ñÌXy[Xð·×Äæè­
void trim(char*str){
	if(' '==*str) strcpy(str,str+1);
	if(*str++) trim(str);
}

//¶ñðg[N²ÆÉØèoµ
void token(char*str,std::vector<std::string>*data){
	char pos;
	std::string strpos="";
	while(pos=*str++){
		switch (pos){
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			strpos=strpos+pos;
			break;
		case '+':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("+");
			break;
		case '-':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("-");
			break;
		case '*':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("*");
			break;
		case '/':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("/");
			break;
		case '(':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("(");
			break;
		case ')':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back(")");
			break;
		default:
			break;
		}
	}
	if(strpos!="") data->push_back(strpos);
}

//g[NÅ é©mF
bool isToken(std::string str){
	if(str=="+" || str=="-" || str=="*" || str=="/") return true;
	return false;
}

//g[NÌ®`·é
void tokenAna(std::vector<std::string>*in,std::vector<std::string>*out){
	if(isToken((*in)[0])){
		(*in)[1]=(*in)[0]+(*in)[1];
	}else{
		out->push_back((*in)[0]);
	}

	for(int i=1;i<in->size();i++) {
		if(isToken((*in)[i])){
			if(isToken((*in)[i-1])){
				(*in)[i+1]=(*in)[i]+(*in)[i+1];
			}else{
				if((*in)[i-1]=="("){
					(*in)[i+1]=(*in)[i]+(*in)[i+1];
				}else{
					out->push_back((*in)[i]);
				}
			}
		}else{
			out->push_back((*in)[i]);
		}
	}
}



//t|[h@ÉÏ··é½ßÌZqÌDæÊðè
int Priority(const char*str){
	if(0==strcmp(str,"+")) return 10;
	if(0==strcmp(str,"-")) return 10;
	if(0==strcmp(str,"*")) return 20;
	if(0==strcmp(str,"/")) return 20;
	return 0;
}

//®ðt|[h@ÉÏ·
void Analyzer(std::vector<std::string>*data,std::vector<std::string>*out,int*i){
	std::stack<const char*> stack;

	for(;*i<data->size();(*i)++){
		if((*data)[*i]=="+" || (*data)[*i]=="-" || (*data)[*i]=="*" || (*data)[*i]=="/"){
			while(stack.empty()==false && //false : X^bNÉlª é
				!(Priority((*data)[*i].c_str())>Priority(stack.top()))){ 
					const char*str=stack.top();//ÅãöÌlÌæ¾
					stack.pop();//ÅãöÌlÌí
					out->push_back(str);
			}
			stack.push((*data)[*i].c_str());//lÌÇÁ
		}else{
			if((*data)[*i]=="("){
				*i=*i+1;
				Analyzer(data,out,i);
			}else{
				if((*data)[*i]==")"){
					goto end;
				}else{
					out->push_back((*data)[*i]);
				}
			}
		}
	}
end:
	while(stack.empty()==false){//false : X^bNÉlª é
		const char*str=stack.top();//ÅãöÌlÌæ¾
		stack.pop();//ÅãöÌlÌí
		out->push_back(str);
	}
}

//t|[h@\LÌvZ®ðvZ
double calc(std::vector<std::string>*out){
	int c=out->size();
	std::stack<double> stack;
	double j,k;
	for(int i=0;i<c;i++){
			if((*out)[i]== "+"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k+j);
			}else if((*out)[i]=="-"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k-j);
			}else if((*out)[i]=="*"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k*j);
			}else if((*out)[i]=="/"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k/j);
			}else{
				stack.push(atof((*out)[i].c_str()));
			}
		}
	return stack.top();
}

int main(){
//	printf("%s\n","((-10+-20)*((30+40))+1)*2 [Enter] ÌlÉüÍµÄ­¾³¢");
//	printf("--------------------------------------\n");
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		std::vector<std::string> data;
		std::vector<std::string> out;

		//¶ñÆµÄüÍ
		char str[1024];
		scanf("%s",str);
		trim(str);
		token(str,&data);
		
		std::vector<std::string> data2;
		tokenAna(&data,&data2);

		//{printf("g[NØèoµÊ : ");for(int a=0;a<data2.size();a++) printf("%s ",data2[a].c_str());}
		
		int c=0;
		Analyzer(&data2,&out,&c);

		//{printf("\nt|[h@ÉÏ· : ");for(int a=0;a<out.size();a++) printf("%s ",out[a].c_str());}
		//printf("\nvZÊ : ");
		printf("%g\n",calc(&out));
		//printf("--------------------------------------\n");
	}
	return 0;
}