#include<stdio.h>
#include<string.h>

int n;
char buff[17][10];

int calc(int line) {
	char c;
	int level, val, arg;
	level = strlen(buff[line]) - 1;
	c = buff[line][level];
	switch(c){
	case'*':
		line++;
		val = 1;
		while (1){
			if (strlen(buff[line]) - 1 <= level)break;
			if (strlen(buff[line]) - 1 == level + 1) {
				arg = calc(line);
				val *= arg;
			}
			line++;
			if (line >= n)break;
		}
		return val;
	case'+':
		line++;
		val = 0;
		while (1) {
			if (strlen(buff[line]) - 1 <= level)break;
			if (strlen(buff[line]) - 1 == level + 1) {
				arg = calc(line);
				val += arg;
			}
			line++;
			if (line >= n)break;
		}
		return val;
	default:
		return c;
		break;
	}
}

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)return 0;;
		for (int i = 0; i < n; i++) {
			scanf("%s", buff[i][0]);
			printf("%d\n", calc(0));
		}
	}
}
