/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone{
	public static class Node{
		int level;
		List<Node> children = new ArrayList<Node>();
		Node(int level){
			this.level = level;
		}
		
		@Override public String toString(){
			StringBuilder sb = new StringBuilder();
			for(int i=1; i<level; i++)
				sb.append("\t");
			sb.append("H" + level + "\n");
			for(Node n : children)
				sb.append(n.toString());
			
			return sb.toString();
		}
	}
	
	public static void main (String[] args) throws java.lang.Exception{
		String[] h = {"H1", "H1", "H2", "H3", "H3", "H2", "H2", "H3",
		                    "H4", "H2", "H2", "H2", "H1", "H2", "H2", "H3",
		                    "H4", "H4", "H2"};
		                    
		Node[] mostRecent = new Node[5];
		mostRecent[0] = new Node(0);     // root node
		
		for(int i = 0; i < h.length; i++){
			int level = Integer.parseInt("" + h[i].charAt(1));
			Node n = new Node(level);
			mostRecent[level - 1].children.add(n);
			mostRecent[level] = n;
		} 
		
		System.out.print(mostRecent[0]);
	}
}