Problem: A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.

Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of English alphabet. Comments have tree-like structure, that means each comment except root comments (comments of the highest level) has exactly one parent comment.

When Polycarp wants to save comments to his hard drive he uses the following format. Each comment he writes in the following format: 

  * at first, the text of the comment is written; 
  * after that the number of comments is written, for which this comment is a parent comment (i. e. the number of the replies to this comments); 
  * after that the comments for which this comment is a parent comment are written (the writing of these comments uses the same algorithm). 

All elements in this format are separated by single comma. Similarly, the comments of the first level are separated by comma.

For example, if the comments look like:

<image>

then the first comment is written as "hello,2,ok,0,bye,0", the second is written as "test,0", the third comment is written as "one,1,two,2,a,0,b,0". The whole comments feed is written as: "hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0". For a given comments feed in the format specified above print the comments in a different format: 

  * at first, print a integer d — the maximum depth of nesting comments; 
  * after that print d lines, the i-th of them corresponds to nesting level i; 
  * for the i-th row print comments of nesting level i in the order of their appearance in the Policarp's comments feed, separated by space. 

Input

The first line contains non-empty comments feed in the described format. It consists of uppercase and lowercase letters of English alphabet, digits and commas. 

It is guaranteed that each comment is a non-empty string consisting of uppercase and lowercase English characters. Each of the number of comments is integer (consisting of at least one digit), and either equals 0 or does not contain leading zeros.

The length of the whole string does not exceed 106. It is guaranteed that given structure of comments is valid. 

Output

Print comments in a format that is given in the statement. For each level of nesting, comments should be printed in the order they are given in the input.

Examples

Input

hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0


Output

3
hello test one 
ok bye two 
a b 


Input

a,5,A,0,a,0,A,0,a,0,A,0


Output

2
a 
A a A a A 


Input

A,3,B,2,C,0,D,1,E,0,F,1,G,0,H,1,I,1,J,0,K,1,L,0,M,2,N,0,O,1,P,0


Output

4
A K M 
B F H L N O 
C D G I P 
E J 

Note

The first example is explained in the statements. 

Solution (in JAVA):

Solution:

import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;
	
	
	 public class Palindrome {
		static double eps=(double)1e-6;
		static long mod=(long)1e9+7;
		static int maxcount=0;
		
		
		public static void main(String args[]){
			InputReader in = new InputReader(System.in);
			OutputStream outputStream = System.out;
			PrintWriter out = new PrintWriter(outputStream);
			Scanner sc=new Scanner(System.in);
			
			//----------My Code----------
			String s=in.nextLine();
			HashMap<String,Integer> hm=new HashMap<String, Integer>();
			ArrayList<ArrayList<Integer>> arr=new ArrayList<ArrayList<Integer>>();
			for(int i=0;i<s.length()/2;i++)
				arr.add(new ArrayList<Integer>());
			String sp[]=s.split(",");
			int index=0;
			Stack<Pair> l=new Stack<Pair>();
			ArrayList<Integer> par=new ArrayList<Integer>();
			for(int i=0;i<sp.length;i+=2){
				
				//System.out.println(sp[i]+" "+index);
				arr.get(i).add(i);
				int nextlevel=Integer.parseInt(sp[i+1]);
				
				if(!l.isEmpty()){
					
					arr.get(l.peek().x).add(i);
					Pair p=(Pair)l.peek();
					p.y-=1;	
					//System.out.println(l.peek().y+" "+l.peek().x);
				}
				l.push(new Pair(i,nextlevel));
				while(!l.isEmpty()&&((Pair)l.peek()).y==0){
					//System.out.println(l.peek().x);
					if(l.size()==1)
						par.add(l.peek().x);
					l.pop();
				}
				index++;
			}
			LinkedList<Integer> q=new LinkedList<Integer>();
			HashMap<Integer,ArrayList<Integer>> jj=new HashMap<Integer,ArrayList<Integer>>();
			int a[]=new int[sp.length/2];
			//System.out.println(par);
			int maxlevel=0;
			for(int j=0;j<par.size();j++){
			q.add(par.get(j));
			int curlevel=1;
			int nextlevel=0;
			int level=1;
			while(!q.isEmpty()){
				int rem=q.removeFirst();
				int i=1;
				if (curlevel == 0) {
		            level++;
		            curlevel = nextlevel;
		            nextlevel = 0;
		        }	
				while(i<arr.get(rem).size()){
					q.add(arr.get(rem).get(i));
					nextlevel++;
					i++;
				}
				curlevel--;
				if(jj.get(level)==null)
					jj.put(level,new ArrayList<Integer>());
				jj.get(level).add(rem);
			
			}
			maxlevel=Math.max(maxlevel, level);
			
			}
			out.println(maxlevel);
			for(int i=1;i<=maxlevel;i++){
				for(int x:jj.get(i)){
					out.print(sp[x]+" ");
				}
				out.println();
			}
			
			
			//-- -------------The End------------------
			out.close();
		}
		
		
		
		static int recursiveBinarySearch(int[] sortedArray, int start, int end, int key) {
	
		while (start < end) {
				int mid = start + (end - start) / 2; 
				if (key < sortedArray[mid]) {
					end=mid-1;
	
				} else if (key >=sortedArray[mid]) {
					start=mid+1;
				}
			}
			return (start); 
		}
	
		static long modulo(long a,long b,long c) {
			long x=1;
			long y=a;
			while(b > 0){
				if(b%2 == 1){
					x=(x*y)%c;
				}
			
				y = (y*y)%c; // squaring the base
				b /= 2;
			}
			return  x%c;
		}
		
		
		static long gcd(long x, long y)
		
		{
			long r=0, a, b;
			a = (x > y) ? x : y; // a is greater number
			b = (x < y) ? x : y; // b is smaller number
			r = b;
			while(a % b != 0)
			{
				r = a % b;
				a = b;
				b = r;
			}
			return r;
		}
		static class Pair implements Comparable<Pair> {
			int x;
			int y;
			//int i;
			Pair(int  xx,int yy){
				
				x=xx;
				y=yy;
				//i=ii;
			}
			@Override
			public int compareTo(Pair arg0) {
			
				
				
					return 1;
				
				
			}
		
		}
		static class InputReader {
			public BufferedReader reader;
			public StringTokenizer tokenizer;
	
			public InputReader(InputStream inputstream) {
				reader = new BufferedReader(new InputStreamReader(inputstream));
				tokenizer = null;
			}
	
			public String nextLine(){
				String fullLine=null;
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						fullLine=reader.readLine();
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
					return fullLine;
				}
				return fullLine;
			}
			public String next() {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
				return tokenizer.nextToken();
			}
			public long nextLong() {
				return Long.parseLong(next());
			}
			public int nextInt() {
				return Integer.parseInt(next());
			}
		}
	}