#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    stack<int> st;
    stack<char> now;
    string s;
    while(!st.empty()) st.pop();
    while(!now.empty() ) now.pop();
    rep(i,n){
      cin>>s;
      int level=0;
      rep(j,s.size() ){
	if(s[j]=='.') level++;
      }
      while(st.size() >level){
	int num=st.top();
	st.pop();
	now.pop();
	if(now.top() == '+') st.top()+=num;
	else st.top()*=num;
      }
      if(isdigit(s[s.size() - 1])){
	if(now.empty() ){
	  st.push(s[s.size() - 1]-'0');
	}else{
	  if(now.top()=='+'){
	    st.top()+=s[s.size() - 1]-'0';
	  }else{
	    st.top()*=s[s.size() - 1]-'0';
	  }
	}
      }else{
	if(s[s.size() - 1]=='+'){
	  now.push('+');
	  st.push(0);
	  // cout<<'a'<<endl;
	}else{
	  now.push('*');
	  st.push(1);
	}
      }
    }
    while(st.size() != 1){
      int num=st.top();
      st.pop();
      now.pop();
      if(now.top() == '+') st.top()+=num;
      else st.top()*=num;
    }
    cout<<st.top()<<endl;
  }
     
      
  return 0;
}


### Prompt

Your task is to create a CPP solution to the following problem:

ICPC Calculator

In mathematics, we usually specify the order of operations by using parentheses. For example, 7 × (3 + 2) always means multiplying 7 by the result of 3 + 2 and never means adding 2 to the result of 7 × 3. However, there are people who do not like parentheses. International Counter of Parentheses Council (ICPC) is attempting to make a notation without parentheses the world standard. They are always making studies of such no-parentheses notations.

Dr. Tsukuba, a member of ICPC, invented a new parenthesis-free notation. In his notation, a single expression is represented by multiple lines, each of which contains an addition operator (+), a multiplication operator (*) or an integer. An expression is either a single integer or an operator application to operands. Integers are denoted in decimal notation in one line. An operator application is denoted by a line of its operator immediately followed by lines denoting its two or more operands, each of which is an expression, recursively. Note that when an operand is an operator application, it comprises multiple lines.

As expressions may be arbitrarily nested, we have to make it clear which operator is applied to which operands. For that purpose, each of the expressions is given its nesting level. The top level expression has the nesting level of 0. When an expression of level n is an operator application, its operands are expressions of level n + 1. The first line of an expression starts with a sequence of periods (.), the number of which indicates the level of the expression.

For example, 2 + 3 in the regular mathematics is denoted as in Figure 1. An operator can be applied to two or more operands. Operators + and * represent operations of summation of all operands and multiplication of all operands, respectively. For example, Figure 2 shows an expression multiplying 2, 3, and 4. For a more complicated example, an expression (2 + 3 + 4) × 5 in the regular mathematics can be expressed as in Figure 3 while (2 + 3) × 4 × 5 can be expressed as in Figure 4.


+
.2
.3


Figure 1: 2 + 3




*
.2
.3
.4


Figure 2: An expression multiplying 2, 3, and 4




*
.+
..2
..3
..4
.5


Figure 3: (2 + 3 + 4) × 5




*
.+
..2
..3
.4
.5


Figure 4: (2 + 3) × 4 × 5



Your job is to write a program that computes the value of expressions written in Dr. Tsukuba's notation to help him.

Input

The input consists of multiple datasets. Each dataset starts with a line containing a positive integer n, followed by n lines denoting a single expression in Dr. Tsukuba's notation.

You may assume that, in the expressions given in the input, every integer comprises a single digit and that every expression has no more than nine integers. You may also assume that all the input expressions are valid in the Dr. Tsukuba's notation. The input contains no extra characters, such as spaces or empty lines.

The last dataset is immediately followed by a line with a single zero.

Output

For each dataset, output a single line containing an integer which is the value of the given expression.

Sample Input


1
9
4
+
.1
.2
.3
9
+
.0
.+
..*
...1
...*
....1
....2
..0
10
+
.+
..6
..2
.+
..1
..*
...7
...6
.3
0


Output for the Sample Input


9
6
2
54






Example

Input

1
9
4
+
.1
.2
.3
9
+
.0
.+
..*
...1
...*
....1
....2
..0
10
+
.+
..6
..2
.+
..1
..*
...7
...6
.3
0


Output

9
6
2
54

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    stack<int> st;
    stack<char> now;
    string s;
    while(!st.empty()) st.pop();
    while(!now.empty() ) now.pop();
    rep(i,n){
      cin>>s;
      int level=0;
      rep(j,s.size() ){
	if(s[j]=='.') level++;
      }
      while(st.size() >level){
	int num=st.top();
	st.pop();
	now.pop();
	if(now.top() == '+') st.top()+=num;
	else st.top()*=num;
      }
      if(isdigit(s[s.size() - 1])){
	if(now.empty() ){
	  st.push(s[s.size() - 1]-'0');
	}else{
	  if(now.top()=='+'){
	    st.top()+=s[s.size() - 1]-'0';
	  }else{
	    st.top()*=s[s.size() - 1]-'0';
	  }
	}
      }else{
	if(s[s.size() - 1]=='+'){
	  now.push('+');
	  st.push(0);
	  // cout<<'a'<<endl;
	}else{
	  now.push('*');
	  st.push(1);
	}
      }
    }
    while(st.size() != 1){
      int num=st.top();
      st.pop();
      now.pop();
      if(now.top() == '+') st.top()+=num;
      else st.top()*=num;
    }
    cout<<st.top()<<endl;
  }
     
      
  return 0;
}


```