Problem: Consider a data structure called BUT (Binary and/or Unary Tree). A BUT is defined inductively as follows:

* Let l be a letter of the English alphabet, either lowercase or uppercase (n the sequel, we say simply "a letter"). Then, the object that consists only of l, designating l as its label, is a BUT. In this case, it is called a 0-ary BUT.
* Let l be a letter and C a BUT. Then, the object that consists of l and C, designating l as its label and C as its component, is a BUT. In this case, it is called a unary BUT.
* Let l be a letter, L and R BUTs. Then, the object that consists of l, L and R, designating l as its label, L as its left component, and R as its right component, is a BUT. In this case, it is called a binary BUT.



A BUT can be represented by a expression in the following way.

* When a BUT B is 0-ary, its representation is the letter of its label.
* When a BUT B is unary, its representation is the letter of its label followed by the parenthesized representation of its component.
* When a BUT B is binary, its representation is the letter of its label, a left parenthesis, the representation of its left component, a comma, the representation of its right component, and a right parenthesis, arranged in this order.



Here are examples:


a
A(b)
a(a,B)
a(B(c(D),E),f(g(H,i)))


Such an expression is concise, but a diagram is much more appealing to our eyes. We prefer a diagram:


D  H i
-  ---
c E g
--- -
B  f
----
a


to the expression


a(B(c(D),E),f(g(H,i)))


Your mission is to write a program that converts the expression representing a BUT into its diagram. We want to keep a diagram as compact as possible assuming that we display it on a conventional character terminal with a fixed pitch font such as Courier. Let's define the diagram D for BUT B inductively along the structure of B as follows:


* When B is 0-ary, D consists only of a letter of its label. The letter is called the root of D, and also called the leaf of D
* When B is unary, D consists of a letter l of its label, a minus symbol S, and the diagram C for its component, satisfying the following constraints:
* l is just below S
* The root of C is just above S
l is called the root of D, and the leaves of C are called the leaves of D.
* When B is binary, D consists of a letter l of its label, a sequence of minus symbols S, the diagram L for its left component, and the diagram R for its right component, satisfying the following constraints:
* S is contiguous, and is in a line.
* l is just below the central minus symbol of S, where, if the center of S locates on a minus symbol s, s is the central, and if the center of S locates between adjacent minus symbols, the left one of them is the central.
* The root of L is just above the left most minus symbols of S, and the rot of R is just above the rightmost minus symbol of S
* In any line of D, L and R do not touch or overlap each other.
* No minus symbols are just above the leaves of L and R.
l is called the root of D, and the leaves of L and R are called the leaves of D



Input

The input to the program is a sequence of expressions representing BUTs. Each expression except the last one is terminated by a semicolon. The last expression is terminated by a period. White spaces (tabs and blanks) should be ignored. An expression may extend over multiple lines. The number of letter, i.e., the number of characters except parentheses, commas, and white spaces, in an expression is at most 80.

You may assume that the input is syntactically correct and need not take care of error cases.

Output

Each expression is to be identified with a number starting with 1 in the order of occurrence in the input. Output should be produced in the order of the input.

For each expression, a line consisting of the identification number of the expression followed by a colon should be produced first, and then, the diagram for the BUT represented by the expression should be produced.

For diagram, output should consist of the minimum number of lines, which contain only letters or minus symbols together with minimum number of blanks required to obey the rules shown above.

Examples

Input

a(A,b(B,C));
x( y( y( z(z), v( s, t ) ) ), u ) ;

a( b( c,
      d(
         e(f),
         g
       )
    ),
   h( i(
         j(
            k(k,k),
            l(l)
          ),
         m(m)
       )
    )
 );

a(B(C),d(e(f(g(h(i(j,k),l),m),n),o),p))
.


Output

1:
 B C
 ---
A b
---
 a
2:
z s t
- ---
z  v
----
 y
 -
 y u
 ---
  x
3:
   k k l
   --- -
 f  k  l m
 -  ---- -
 e g j   m
 --- -----
c d    i
---    -
 b     h
 -------
    a
4:
j k
---
 i l
 ---
  h m
  ---
   g n
   ---
    f o
    ---
   C e p
   - ---
   B  d
   ----
    a


Input

a(A,b(B,C));
x( y( y( z(z), v( s, t ) ) ), u ) ;

a( b( c,
d(
e(f),
g
)
),
h( i(
j(
k(k,k),
l(l)
),
m(m)
)
)
);

a(B(C),d(e(f(g(h(i(j,k),l),m),n),o),p))
.


Output

1:
B C
---
A b
---
a
2:
z s t
- ---
z  v
----
y
-
y u
---
x
3:
k k l
--- -
f  k  l m
-  ---- -
e g j   m
--- -----
c d    i
---    -
b     h
-------
a
4:
j k
---
i l
---
h m
---
g n
---
f o
---
C e p
- ---
B  d
----
a

Solution (in CPP):

Solution:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

class Tree{
public:
  Tree *l,*r;
  char c;
  int x,y;
  int d;
  Tree():l(NULL),r(NULL),d(0){;}
};

//parsig
Tree *parse(string &in,int &p);
void destoroy(Tree *in);
bool getdata(string &in);

//debug
void travarse(Tree *in);

const int R = 200,C=500;
char m[R][C];

int get_space(int dl,int *l,int dr,int *r){
  int ret=0;
  for(int i=0;i<min(dr,dl);i++){
    ret=max(ret,l[i]+r[i]+2);//kankaku + below the node
    if (i+1 != dl){
      ret=max(ret,l[i+1]+r[i]+1);
    }
    if (i+1 != dr){
      ret=max(ret,l[i]+r[i+1]+1);
    }
  }
  return ret;
}

void merge(int dl,int *l,int dr,int *r,int dist,int opdist){
  int i=0;
  for(i=0;i<dl;i++){
    l[i]+=dist;
  }

  for(;i<dr;i++){//higher ??
    l[i]=r[i]-opdist;
  }
}

int make_pos(Tree *now,int *l,int *r){//return height
  int height=0;
  l[0]=0;
  r[0]=0;
  if (now->l == NULL){//0 node
    height=0;
  }else if (now->r == NULL){//1 node
    height=make_pos(now->l,l+1,r+1);
  }else{//two node
    int tl[R],tr[R];
    int dl = make_pos(now->l,l+1,tr);
    int dr = make_pos(now->r,tl ,r+1);
    
    now->d = get_space(dr,tl,dl,tr);

    int depth = max(dl,dr);
    merge(dl,l+1,depth,tl,(now->d+0)/2,(now->d+1)/2);
    merge(dr,r+1,depth,tr,(now->d+1)/2,(now->d+0)/2);
    height = depth;
    
  }
  return height+1;
}


void put_tree(int depth,int x,Tree *now){
  m[depth][x]=now->c;
  if (now->l == NULL){
  }else if (now ->r == NULL){
    m[depth+1][x]='-';
    put_tree(depth+2,x,now->l);
  }else {
    for(int i=x-now->d/2;i <= x+(now->d+1)/2 ; i++)
      m[depth+1][i]='-';
    put_tree(depth+2,x-now->d/2,now->l);
    put_tree(depth+2,x+(now->d+1)/2,now->r);
  }
}

int main(){
  int tc = 1;
  while(true){
    string in="";
 
    bool isend=getdata(in);
    fill(&m[0][0],&m[R][0],' ');
    int p = 0;
    Tree *root = parse(in,p);
    
    
    int tl[R],tr[R];
    rep(i,R)tl[i]=tr[i]=-1;


    
    cout << tc++<<":"<<endl;
    int tmp=make_pos(root,tl,tr);
    //    travarse(root);
    int findwid=0;
    rep(i,tmp){
      if (tl[i]<0)findwid=max(findwid,-tl[i]);
      else findwid=max(findwid,tl[i]);
      if (tr[i]<0)findwid=max(findwid,-tr[i]);
      else findwid=max(findwid,tr[i]);
    }

    put_tree(0,findwid+1,root);
    
    int l,r,u,d;
    for(d=0;d<R;d++){
      bool flag=false;
      rep(j,C)if(m[d][j] != ' '){flag=true;break;}
      if (flag){break;}
    }

    for(u=R-1;u>=0;u--){
      bool flag=false;
      rep(j,C)if (m[u][j] != ' '){flag=true;break;}
      if (flag){u++;break;}
    }

    for(l=0;l<C;l++){
      bool flag = false;
      REP(i,d,u)if (m[i][l] != ' '){flag=true;break;}
      if (flag){break;}
    }
    
    for(r =C-1;r>=0;r--){
      bool flag=false;
      REP(i,d,u)if (m[i][r] != ' '){flag=true;break;}
      if (flag){r++;break;}
    }
    
    for(int i=u-1;i>=d;i--){
      r = 0;
      rep(j,C)if (m[i][j] != ' ')r=j+1;
      REP(j,l,r)cout << m[i][j];
      cout << endl;
    }

    
    destoroy(root);

    if (isend)break;
  }
}


//parsing
Tree* parse(string &in,int &p){
  Tree *now;
  now = new Tree();
  now->c = in[p];

  p++;
  if (p < in.size() && in[p] != '('){//leaf
    ;
  }else{//
    p++;
    now->l = parse(in,p);
    if (in[p] == ')'){
    }else if (in[p] == ','){
      p++;
      int tmp = 0;
      now->r=parse(in,p);
    }
    p++;
  }
  return now;
}



void destoroy(Tree *in){
  if (in->l != NULL)destoroy(in->l);
  if (in->r != NULL)destoroy(in->r);
  free(in);
}

bool getdata(string &in){
  bool isend=false;
  while(true){
    char c = getchar();
    if (c == ';')break;
    if (c == '.'){
      isend=true;
      break;
    }    
    if (isalpha(c) || c == '(' || c == ')' || c == ',')in+=c;
  }
  return isend;
}



void travarse(Tree *in){
  cout << in->c <<" dist " << in->d;
  if (in->l != NULL)cout << " l: "<<in->l->c;
  if (in->r != NULL)cout << " r: "<<in->r->c;
  cout << endl;
  if (in->l != NULL)travarse(in->l);
  if (in->r != NULL)travarse(in->r);
}