#include<stdio.h>
char s[1010][1010];
int r;
int f(int j){
  int o=s[r][j]-'*'?0:1,ans=o,n;
  while(s[r+1][j]=='.'){
    r++;
    if(s[r][j+1]=='+'||s[r][j+1]=='*')n=f(j+1);
    else      n=s[r][j+1]-'0';//printf("%d %d ",r,n);
    if(o)ans*=n;
    else ans+=n;//printf("%d\n",ans);
  }
  return ans;
}
int main(){
  int n,i;
  while(scanf("%d",&n),n){
    for(i=0;i<1000*1000;i++)s[i/1000][1%1000]=0;
    for(i=0;i<n;i++)scanf("%s",s[i]);
    printf("%d\n",n-1?f(r=0):s[0][0]-'0');
  }
  return 0;
}