class TreeNode:
    def __init__(self):
        self.children = {}  # 存储子目录

def insert_path(root, path):
    # 按'\'分割路径
    dirs = path.strip('\\').split('\\')
    current = root
    
    # 将路径插入到树中
    for d in dirs:
        if d:  # 忽略空目录名
            if d not in current.children:
                current.children[d] = TreeNode()
            current = current.children[d]

def print_tree(node, prefix="", is_root=True):
    # 获取并排序子目录
    dirs = sorted(node.children.keys())
    
    # 打印每个子目录
    for d in dirs:
        print(f"{prefix}{d}")
        # 递归打印子目录,增加缩进
        print_tree(node.children[d], prefix + "  ", False)

def main():
    while True:
        n = int(input())
        if n == 0:
            break
            
        # 创建根节点
        root = TreeNode()
        
        # 读取并处理所有路径
        for _ in range(n):
            path = input().strip()
            insert_path(root, path)
        
        # 打印目录树
        print_tree(root)
        print()  # 每个测试用例后打印空行

if __name__ == "__main__":
    main()