{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e Coach Pang has a lot of hobbies. One of them is playing with “tag soup” with the help of Beautiful Soup. Coach Pang is satisfied with Beautiful Soup in every respect, except the prettify() method, which attempts to turn a soup into a nicely formatted string. He decides to rewrite the method to prettify a HTML document according to his personal preference. But Coach Pang is always very busy, so he gives this task to you. Considering that you do not know anything about “tag soup” or Beautiful Soup, Coach Pang kindly left some information with you:\u003cbr\u003e In Web development, “tag soup” refers to formatted markup written for a web page that is very much like HTML but does not consist of correct HTML syntax and document structure. In short, “tag soup” refers to messy HTML code.\u003cbr\u003e Beautiful Soup is a library for parsing HTML documents (including “tag soup”). It parses “tag soup” into regular HTML documents, and creates parse trees for the parsed pages.\u003cbr\u003e The parsed HTML documents obey the rules below.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eHTML\u003c/b\u003e\u003cbr\u003e HTML stands for HyperText Markup Language.\u003cbr\u003e HTML is a markup language.\u003cbr\u003e A markup language is a set of markup tags.\u003cbr\u003e The tags describe document content.\u003cbr\u003e HTML documents consist of tags and texts.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eTags\u003c/b\u003e\u003cbr\u003e HTML is using tags for its syntax.\u003cbr\u003e A tag is composed with special characters: ‘\u0026lt;’, ‘\u0026gt;’ and ‘/’.\u003cbr\u003e Tags usually come in pairs, the opening tag and the closing tag.\u003cbr\u003e The opening tag starts with “\u0026lt;” and the tagname. It usually ends with a “\u0026gt;”.\u003cbr\u003e The closing tag starts with “\u0026lt;/” and the same tagname as the corresponding opening tag. It ends with a “\u0026gt;”.\u003cbr\u003e There will not be any other angle brackets in the documents.\u003cbr\u003e Tagnames are strings containing only lowercase letters.\u003cbr\u003e Tags will contain no line break (‘\\n’).\u003cbr\u003e Except tags, anything occured in the document is considered as text content.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eElements\u003c/b\u003e\u003cbr\u003e An element is everything from an opening tag to the matching closing tag (including the two tags).\u003cbr\u003e The element content is everything between the opening and the closing tag.\u003cbr\u003e Some elements may have no content. They’re called empty elements, like \u0026lt;hr\u0026gt;\u0026lt;/hr\u0026gt;.\u003cbr\u003e Empty elements can be closed in the opening tag, ending with a “/\u0026gt;” instead of “\u0026gt;”.\u003cbr\u003e All elements are closed either with a closing tag or in the opening tag.\u003cbr\u003e Elements can have attributes.\u003cbr\u003e Elements can be nested (can contain other elements).\u003cbr\u003e The \u0026lt;html\u0026gt; element is the container for all other elements, it will not have any attributes.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eAttributes\u003c/b\u003e\u003cbr\u003e Attributes provide additional information about an element.\u003cbr\u003e Attributes are always specified in the opening tag after the tagname.\u003cbr\u003e Tag name and attributes are separated by single space.\u003cbr\u003e An element may have several attributes.\u003cbr\u003e Attributes come in name\u003d\"value\" pairs like class\u003d\"icpc\".\u003cbr\u003e There will not be any space around the \u0027\u003d\u0027.\u003cbr\u003e All attribute names are in lowercase.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eA Simple Example\u003c/b\u003e \u0026lt;a href\u003d\"http://icpc.baylor.edu/\"\u0026gt;ACM-ICPC\u0026lt;/a\u0026gt;\u003cbr\u003e The \u0026lt;a\u0026gt; element defines an HTML link with the \u0026lt;a\u0026gt; tag.\u003cbr\u003e The link address is specified in the href attribute.\u003cbr\u003e The content of the element is the text “ACM-ICPC”\u003cbr\u003e \u003cbr\u003e You are feeling dizzy after reading all these, when Coach Pang shows up again. He starts to spout for hours about his personal preference and you catch his main points with difficulty. Coach Pang says:\u003cbr\u003e\u003cbr\u003e Your task is to write a program that will turn parsed HTML documents into formatted parse trees. You should print each tag or text content on its own line preceded by a number of spaces that indicate its depth in the parse tree. The depth of the root of the a parse tree (the \u0026lt;html\u0026gt; tag) is 0. He is satisfied with the tags, so you shouldn’t change anything of any tag. For text content, throw away unnecessary white spaces including space (ASCII code 32), tab (ASCII code 9) and newline (ASCII code 10), so that words (sequence of characters without white spaces) are separated by single space. There should not be any trailing space after each line nor any blank line in the output. The line contains only white spaces is also considered as blank line. You quickly realize that your only job is to deal with the white spaces.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" The first line of the input is an integer T representing the number of test cases.\u003cbr\u003e Each test case is a valid HTML document starts with a \u0026lt;html\u0026gt; tag and ends with a \u0026lt;/html\u0026gt; tag. See sample below for clarification of the input format.\u003cbr\u003e The size of the input file will not exceed 20KB."}},{"title":"Output","value":{"format":"HTML","content":" For each test case, first output a line “Case #x:”, where x is the case number (starting from 1).\u003cbr\u003e Then you should write to the output the formatted parse trees as described above. See sample below for clarification of the output format."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n\r\n\u003ch1\u003eACM\r\nICPC\u003c/h1\u003e\r\n\u003cp\u003eHello\nWorld\u003c/p\u003e\r\n\r\n\u003cp\u003e\r\nAsia Chengdu Regional\u003c/p\u003e\r\n\u003cp class\u003d\"icpc\"\u003e\r\nACM-ICPC\u003c/p\u003e\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e[pre]Case #1:\r\n\r\n \r\n \u003ch1\u003e\r\n ACM ICPC\r\n \u003c/h1\u003e\r\n \u003cp\u003e\r\n Hello\r\n \n\r\n World\r\n \u003c/p\u003e\r\n \r\n\r\nCase #2:\r\n\r\n \r\n \u003cp\u003e\r\n Asia Chengdu Regional\r\n \u003c/p\u003e\r\n \u003cp class\u003d\"icpc\"\u003e\r\n ACM-ICPC\r\n \u003c/p\u003e\r\n \r\n\r\n[/pre]\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003ePlease be careful of the number of leading spaces of each line in above sample output.\u003cbr\u003e"}}]}