#include<stdio.h>

char ope[20]= {0};
double num[20]= {0};
int count_ope= 0;
int count_num= 0;

void delope(int index){
	for(int i=index ; i<count_ope ; i++){
		ope[i]  = ope[i+1];
		num[i+1]= num[i+2];
	}
	count_ope--;
	count_num--;
}

double cal() {
	count_num= 0;
	count_ope= 0;
	

	while(1) {
		scanf("%f", &num[count_num]);
		count_num++;
		
		scanf("%c", &ope[count_ope]);
		if('\r'==ope[count_ope] || 0==ope[count_ope]) {
			ope[count_ope]= 0;
			break;
		}
		count_ope++;
			  
		  
	}
	/*for(int i=0; i< count_num;i++)
	  printf("num[%d]=%f ", i, num[i]);
	  
	for(int i=0; i< count_ope;i++)
	  printf("ope[%d]=%c ", i, ope[i]);	  */

	for(int i=0 ; i<count_ope ;) {
		if('*'==ope[i]){
			num[i]*= num[i+1];
			delope(i);
		} else if('/'==ope[i]) {
			num[i]/= num[i+1];
			delope(i);
		} else {
			i++;
		}
	}

	for(int i=0 ; i<count_ope ;) {
		if('+'==ope[i]) {
			num[i]+= num[i+1];
			delope(i);
		} else if('-'==ope[i]) {
			num[i]-= num[i+1];
			delope(i);
		} else {
			//printf("error¡I\n");
			i++;
		}
	}
	return num[0];
}

int main() {
	int count= 0;
	scanf("%d", &count);
	for(int i=0 ; i<count ; i++) {
		printf("%.3f\n",cal());
	}
}

