You are given an HTML code snippet of $N$ lines.
 Your task is to detect and print all the HTML tags, attributes and attribute values.

Print the detected items in the following format:

Tag1
Tag2
-> Attribute2[0] > Attribute_value2[0]
-> Attribute2[1] > Attribute_value2[1]
-> Attribute2[2] > Attribute_value2[2]
Tag3
-> Attribute3[0] > Attribute_value3[0]

The -> symbol indicates that the tag contains an attribute. It is immediately followed by the name of the attribute and the attribute value. 

The > symbol acts as a separator of attributes and attribute values.

If an HTML tag has no attribute then simply print the name of the tag.

Note: Do not detect any HTML tag, attribute or attribute value inside the HTML comment tags (<!-- Comments -->). Comments can be multiline.

All attributes have an attribute value.

Input Format

The first line contains an integer $N$, the number of lines in the HTML code snippet.

The next $N$ lines contain HTML code.

Constraints

$0<N<100$

Output Format

Print the HTML tags, attributes and attribute values in order of their occurrence from top to bottom in the snippet.

Format your answers as explained in the problem statement.

Sample Input
9
<head>
<title>HTML</title>
</head>
<object type="application/x-flash" 
  data="your-file.swf" 
  width="0" height="0">
  <!-- <param name="movie" value="your-file.swf" /> -->
  <param name="quality" value="high"/>
</object>

Sample Output
head
title
object
-> type > application/x-flash
-> data > your-file.swf
-> width > 0
-> height > 0
param
-> name > quality
-> value > high

Explanation

head tag: Print the head tag only because it has no attribute.

title tag: Print the title tag only because it has no attribute.

object tag: Print the object tag. In the next $\begin{array}{c}A\end{array}$ lines, print the attributes type, data, width and                     height along with their respective values.

<!-- Comment  --> tag: Don't detect anything inside it.

param tag: Print the param tag. In the next $2$ lines, print the attributes name along with                     their respective values.

Source: hackerrank | Difficulty: EASY


Solutions:
from html.parser import HTMLParser
n = int(input())

class CustomerHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (attr, value) in attrs:
			print('-> {0} > {1}'.format(attr, value))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (attr, value) in attrs:
			print('-> {0} > {1}'.format(attr, value))
parser = CustomerHTMLParser()
for _ in range(n):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
parser = MyHTMLParser()
for n in range(int(input())):
	s = input()
	parser.feed(s)


import html.parser

class HTMLParser(html.parser.HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		self.process_attrs(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self.process_attrs(attrs)

	def process_attrs(self, attrs):
		for (name, value) in attrs:
			print('->', name, '>', value)
data = ''
for _ in range(int(input())):
	data += input()
parser = HTMLParser()
parser.feed(data)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			(name, value) = a
			print('-> {} > {}'.format(name, value))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for a in attrs:
			(name, value) = a
			print('-> {} > {}'.format(name, value))
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


n = input()
from html.parser import HTMLParser
from html.entities import name2codepoint

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> %s > %s' % (attr[0], attr[1]))
inp = ''.join([input() for _ in range(int(n))])
parser = MyHTMLParser()
parser.feed(inp)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + str(attr[1]))

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + str(attr[1]))

	def handle_comment(self, data):
		pass

	def handle_data(self, data):
		pass
N = int(input())
html = ''
for _ in range(N):
	html += input()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> {} > {}'.format(*a))

	def handle_startendtag(self, tag, attrs):
		self.handle_starttag(tag, attrs)
html = '\n'.join([input() for _ in range(int(input()))])
parser = MyHTMLParser()
parser.feed(html)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name, '>', value)

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name, '>', value)
parser = MyHTMLParser()
n = int(input().strip())
for i in range(n):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', ' > '.join(map(str, attr)))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', ' > '.join(map(str, attr)))
html = ''
for i in range(int(input())):
	html += input()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs is not None:
			for a in attrs:
				print('-> {} > {}'.format(*a))
parser = MyHTMLParser()
n = int(input())
h = ''
for _ in range(n):
	h += input()
parser.feed(h)


import re
n = int(input())
s = ''
for i in range(n):
	s += ' ' + input()
while True:
	z = s.find('<!--')
	if z == -1:
		break
	end = s.find('-->', z + 4)
	s = s.replace(s[z:end + 3], '')
i = 0
while i < len(s):
	if s[i] == '<':
		i += 1
		while s[i] == ' ':
			i += 1
		if s[i] == '/':
			while s[i] != '>':
				i += 1
			i += 1
			continue
		tag = ''
		while s[i] != '/' and s[i] != ' ' and (s[i] != '>'):
			tag += s[i]
			i += 1
		print(tag)
		while s[i] != '>':
			if s[i] == ' ' or s[i] == '/':
				i += 1
				continue
			name = ''
			err = False
			while s[i] != '=':
				name += s[i]
				if s[i] == ' ':
					err = True
					break
				i += 1
			if err:
				continue
			while s[i] != '"':
				i += 1
			i += 1
			val = ''
			while s[i] != '"':
				val += s[i]
				i += 1
			print('-> ' + name + ' > ' + val)
			i += 1
	else:
		i += 1


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for x in attrs:
			if x[1]:
				print('-> ' + x[0] + ' > ' + x[1])
			else:
				print('-> ' + x[0] + ' > None')

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for x in attrs:
			if x[1]:
				print('-> ' + x[0] + ' > ' + x[1])
			else:
				print('-> ' + x[0] + ' > None')
parser = MyHTMLParser()
for k in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser

class MYHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs != None:
			for i in range(len(attrs)):
				print('-> ' + attrs[i][0] + ' > ' + attrs[i][1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		if attrs != None:
			for i in range(len(attrs)):
				print('-> ' + attrs[i][0] + ' > ' + attrs[i][1])
parser = MYHTMLParser()
for i in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('->', a[0], '>', a[1])
n = int(input())
htmls = ''
for i in range(n):
	htmls += input()
parser = MyHTMLParser()
parser.feed(htmls)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def __init__(self):
		super(MyHTMLParser, self).__init__()
		self.tags = []

	def __str__(self):
		string = ''
		for (tag, attrs) in self.tags:
			string += tag + '\n'
			for attr in attrs:
				string += ' '.join(['->', str(attr[0]), '>', str(attr[1])])
				string += '\n'
		return string

	def handle_starttag(self, tag, attrs):
		self.tags.append([tag, attrs])

	def handle_starttag(self, tag, attrs):
		self.tags.append([tag, attrs])
N = int(input())
mp = MyHTMLParser()
for index in range(N):
	mp.feed(input())
print(mp)


from html.parser import HTMLParser
N = int(input())
doc = ''
for n in range(N):
	doc = doc + input() + '\n'

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_endtag(self, tag):
		pass

	def handle_data(self, data):
		pass

	def handle_comment(self, data):
		pass
parser = MyHTMLParser()
p = parser.feed(doc)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
N = int(input())
raw = ''
for i in range(N):
	raw += input()
new = MyHTMLParser()
new.feed(raw)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		self._print_attributes(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self._print_attributes(attrs)

	def _print_attributes(self, attrs):
		for (k, v) in attrs:
			print('-> {0} > {1}'.format(k, v))
parser = MyHTMLParser()
for _ in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print('{}'.format(tag))
		if attrs:
			for (attr, val) in attrs:
				print('-> {} > {}'.format(attr, val))

	def handle_startendtag(self, tag, attrs):
		print('{}'.format(tag))
		if attrs:
			for (attr, val) in attrs:
				print('-> {} > {}'.format(attr, val))
parser = MyHTMLParser()
s = ''
for _ in range(int(input())):
	s += input().rstrip()
	s += '\n'
parser.feed(s)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

def print_tag_and_attrs(tag, attrs):
	print(tag)
	for attr in attrs:
		print('->', attr[0], '>', attr[1])

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print_tag_and_attrs(tag, attrs)
html = str()
for i in range(int(input())):
	html += input().rstrip() + '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> %s > %s' % attr if len(attr) > 1 else '-> %s > None' % attr)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> %s > %s' % attr if len(attr) > 1 else '-> %s > None' % attr)
parser = MyHTMLParser()
for i in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser

class Pythonist2Parser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (attr, value) in attrs:
			print('->', attr, '>', value)
parser = Pythonist2Parser()
for _ in range(int(input())):
	parser.feed(input())
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> ' + a[0] + ' > ' + str(a[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> ' + a[0] + ' > ' + str(a[1]))
parser = MyHTMLParser()
n = int(input())
parser.feed(''.join((input() for _ in range(n))))


import re

def parse_properties(text):
	if ' ' in text:
		first = text.strip().find(' ')
		print(text[:first + 1])
		text = text[first + 1:]
		for m in re.finditer('([a-zA-Z0-9-]+)="([^"]+)"', text):
			print('-> %s > %s' % (m.group(1), m.group(2)))
	else:
		print(text)

def parse_html(text):
	index = text.find('<')
	while index >= 0:
		open_tag = index
		if text[open_tag + 1] == '!':
			close_tag = text.find('-->', open_tag + 1)
			index = text.find('<', close_tag + 3)
			continue
		close_tag = text.find('>', open_tag + 1)
		if text[open_tag + 1] != '/':
			sub_text = text[open_tag + 1:close_tag]
			if sub_text[-1] == '/':
				sub_text = sub_text[:-1]
			sub_text = sub_text.strip()
			parse_properties(sub_text)
		index = text.find('<', close_tag + 1)
r = []
for _ in range(int(input())):
	r.append(input())
text = ''.join(r)
parse_html(text)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs != None:
			for attr in attrs:
				print('->', attr[0], '>', attr[1])
		else:
			pass
parser = MyHTMLParser()
N = int(input())
for i in range(N):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs:
			for (attr, value) in attrs:
				print('-> %s > %s' % (attr, value))
N = int(input())
html = ''.join([input() for _ in range(N)])
parser = MyHTMLParser()
parser.feed(html)
parser.close()


import html.parser, contextlib

class HRParser(html.parser.HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (attrn, attrv) in attrs:
			print('->', attrn, '>', attrv)
with contextlib.closing(HRParser()) as hrp:
	for lno in range(int(input())):
		hrp.feed(input())


from html.parser import HTMLParser

class HtmlParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> {0} > {1}'.format(attr[0], attr[1]))
n = int(input())
s = ''
for _ in range(n):
	s += input() + ' '
parser = HtmlParser()
parser.feed(s)


import re
from html.parser import *

class myHTML(HTMLParser):

	def handle_starttag(self, tag, attr):
		print(tag)
		for a in attr:
			print('-> ' + a[0] + ' > ' + str(a[1]))

	def handle_startendtag(self, tag, attr):
		print(tag)
		for a in attr:
			print('-> ' + a[0] + ' > ' + str(a[1]))
parser = myHTML()
s = ''
for _ in range(int(input())):
	s = s + '\n' + input()
parser.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + attr[1])
parser = MyHTMLParser()
n = int(input())
s = ''
for _ in range(n):
	s += input()
parser.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name, '>', value)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name, '>', value)
str = ''
for i in range(int(input())):
	str += input()
parser = MyHTMLParser()
parser.feed(str)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (key, val) in attrs:
			print('-> {0} > {1}'.format(key, val))
parser = MyHTMLParser()
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser.feed(html)
parser.close()


import sys
from html.parser import HTMLParser
rl = lambda : sys.stdin.readline()

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs:
			for attr in attrs:
				print('->', attr[0], '>', attr[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		if attrs:
			for attr in attrs:
				print('->', attr[0], '>', attr[1])
n = int(rl())
html = ''
for _ in range(n):
	html += rl().strip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			if attr[1] != 'None':
				print('-> {0} > {1}'.format(attr[0], attr[1]))
			else:
				print('->', attr[0])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			if attr[1] != 'None':
				print('-> {0} > {1}'.format(attr[0], attr[1]))
			else:
				print('->', attr[0])
parser = MyHTMLParser()
for _ in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser
count = int(input())
final_text = ''
while count > 0:
	text = input()
	final_text = final_text + text
	count = count - 1

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if len(attrs) > 0:
			for (name, value) in attrs:
				print('-> ' + str(name) + ' > ' + str(value))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		if len(attrs) > 0:
			for (name, value) in attrs:
				print('-> ' + str(name) + ' > ' + str(value))
parser = MyHTMLParser()
parser.feed(final_text)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs:
			for a in attrs:
				print('->', a[0], '>', a[1])
html = []
for _ in range(int(input())):
	html.append(input())
parser = MyHTMLParser()
parser.feed(' '.join(html))


from html.parser import HTMLParser
lines = int(input().strip())
rawhtml = ''
for line in range(lines):
	rawhtml += input().strip()

class TagsAndAttrs(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (flag, val) in attrs:
			print('-> {flag} > {val}'.format(flag=flag, val=val))
parser = TagsAndAttrs()
parser.feed(rawhtml)


import re
import sys
re_comment = re.compile('<!--.*?-->', re.DOTALL)
re_tag = re.compile('<\\s*(\\w+)\\s*([^>]*)>', re.DOTALL)
re_attr = re.compile('(\\S+)="([^"]+)"')
html = sys.stdin.read()
for m in re_tag.finditer(re_comment.sub('', html)):
	print(m.group(1))
	for m2 in re_attr.finditer(m.group(2)):
		print('-> %s > %s' % (m2.group(1), m2.group(2)))


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for x in attrs:
			print('-> {} > {}'.format(x[0], x[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for x in attrs:
			print('-> {} > {}'.format(x[0], x[1]))
parser = MyHTMLParser()
this = ''
for _ in range(int(input())):
	this += input()
parser.feed(this)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
n = int(input())
data = ''
for i in range(n):
	data += input()
parser = MyHTMLParser()
parser.feed(data)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
parser = MyHTMLParser()
N = int(input())
html = ''.join((input() for _ in range(N)))
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for e in attrs:
			print('-> ' + e[0] + ' > ' + str(e[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for e in attrs:
			print('-> ' + e[0] + ' > ' + str(e[1]))
parser = MyHTMLParser()
N = int(input())
for _ in range(N):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (attr, value) in attrs:
			print('->', attr, '>', value)

	def handle_endtag(self, tag):
		pass

	def handle_data(self, data):
		pass

	def handle_comment(self, data):
		pass

	def handle_entityref(self, name):
		pass

	def handle_charref(self, name):
		pass

	def handle_decl(self, data):
		pass

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (attr, value) in attrs:
			print('->', attr, '>', value)
inp = ''
for i in range(int(input())):
	inp += input()
parser = MyHTMLParser()
parser.feed(inp)


from html.parser import HTMLParser

class TagFinder(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs:
			self.print_attrs(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		if attrs:
			self.print_attrs(attrs)

	def print_attrs(self, attrs):
		for a in attrs:
			print('-> {} > {}'.format(a[0], a[1]))
n = int(input())
html = ''
for _ in range(n):
	html += input()
parser = TagFinder()
parser.feed(html)


import sys
from html.parser import HTMLParser

class Parser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (k, v) in attrs:
			print('-> {} > {}'.format(k, v))
	handle_startendtag = handle_starttag
input()
parser = Parser()
parser.feed(''.join(sys.stdin.readlines()))
parser.close()


from html.parser import HTMLParser
__author__ = 'namii'

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for item in attrs:
			print('-> ' + str(item[0]) + ' > ' + str(item[1]))
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (i, j) in attrs:
			print('->', i, '>', j)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (i, j) in attrs:
			print('->', i, '>', j)
t = int(input())
s = ''
for i in range(t):
	s += input()
par = MyHTMLParser()
par.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for i in attrs:
			print('->', ' > '.join(map(str, i)))
html = ''
for i in range(int(input())):
	html += input()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> %s > %s' % a)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> %s > %s' % a)
m = MyHTMLParser()
for _ in range(int(input())):
	m.feed(input())


import sys
import re
from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		if attrs:
			for attr in attrs:
				print('-> %s > %s' % attr)

	def handle_endtag(self, tag):
		pass

	def handle_data(self, data):
		pass
n = int(input())
html = ''.join(sys.stdin.readlines())
parser = MyHTMLParser()
parser.feed(html)


from html.parser import HTMLParser

class MyParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', ' > '.join(map(str, attr)))
html = ''
for _ in range(int(input())):
	html += input()
	html += '\n'
parser = MyParser()
parser.feed(html)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', ' > '.join(map(str, attr)))

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', ' > '.join(map(str, attr)))
html = ''
for i in range(int(input())):
	html += input()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


import re
import html
from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name + ' >', value)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('->', name + ' >', value)
parser = MyHTMLParser()
n = int(input())
for _ in range(n):
	parser.feed(input())


from html.parser import HTMLParser
html = ''
for i in range(int(input())):
	html += input()

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for item in attrs:
			print('->', item[0], '>', item[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for item in attrs:
			print('->', item[0], '>', item[1])
parser = MyHTMLParser()
parser.feed(html)


from functools import reduce
from html.parser import HTMLParser
import re
txt = reduce(lambda a, b: a + '\n' + b, [input() for _ in range(int(input()))])

class TagParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> ' + a[0] + ' > ' + a[1])
parser = TagParser()
parser.feed(txt)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + str(attr[0]) + ' > ' + str(attr[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + str(attr[0]) + ' > ' + str(attr[1]))
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_comment(self, data):
		print('', end='')
n = int(input())
lines = []
for _ in range(n):
	lines.append(input())
html = '\n'.join(lines)
parser = MyHTMLParser()
parser.feed(html)


from html.parser import HTMLParser

class HTMLDetect(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + attr[1])
detector = HTMLDetect()
N = int(input())
for i in range(0, N):
	s = input()
	detector.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		self.__print_attrs__(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self.__print_attrs__(attrs)

	def __print_attrs__(self, attrs):
		for (name, value) in attrs:
			print('-> {0} > {1}'.format(name, value))
html = ''
for _ in range(int(input())):
	html += input()
p = MyHTMLParser()
p.feed(html)


from html.parser import HTMLParser as HP

class MyParser(HP):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('->', a[0], '>', a[1])
mp = MyParser()
html = ''
for _ in range(int(input())):
	html += input()
mp.feed(html)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
parser = MyHTMLParser()
html_text = ''
n = int(input())
for i in range(0, n):
	html_text += input()
parser.feed(html_text)


import re
N = int(input())
iText_Raw = '\n'.join([input() for i in range(N)])
iText = re.sub('<!--.*?-->', '', iText_Raw, flags=re.DOTALL)
TagDetect = re.finditer('<(\\w.*?)/?>', iText, re.DOTALL)
for tag in TagDetect:
	tagText = tag.group(0)
	tagTitle = re.search('(?<=^<)\\w[-\\w]*', tagText)
	print(tagTitle.group(0))
	contentText = tagText[tagTitle.end():-2] if tagText[-2:] == '/>' else tagText[tagTitle.end():-1]
	contentDetect = re.finditer('(\\w[-\\w]*)=["\'](.*?)["\']|\\w[-\\w]*', contentText)
	for content in contentDetect:
		contText = content.group(0)
		if '=' not in contText:
			print('->', contText, '>', 'None')
		else:
			print('->', content.group(1), '>', content.group(2))


from html.parser import HTMLParser

class MHP(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			(k, v) = a
			print('-> ' + k + ' > ' + v)

	def handle_endtag(self, tag):
		pass

	def handle_data(self, data):
		pass
n = int(input())
p = MHP()
try:
	for i in range(n):
		p.feed(input())
except:
	pass


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print('%s' % str(tag))
		for attr in attrs:
			print('-> %s > %s' % attr)

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attrs):
		print('%s' % str(tag))
		for attr in attrs:
			print('-> %s > %s' % attr)
s = ''
for _ in range(int(input())):
	s += input()
parser = MyHTMLParser()
parser.feed(s)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for e in attrs:
			print('-> ' + e[0] + ' > ' + str(e[1]))

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for e in attrs:
			print('-> ' + e[0] + ' > ' + str(e[1]))
parser = MyHTMLParser()
for _ in range(int(input())):
	parser.feed(input())


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
n = int(input())
s = ''
for i in range(n):
	s += input() + '\n'
parser = MyHTMLParser()
parser.feed(s)


def tagscope(string):
	tstart = string.find('<')
	if tstart > -1:
		tend = min([string[tstart:].find('>'), string[tstart:].find(' ')])
		tagname = string[tstart + 1:tstart + tend]
		tagend = string.rfind('</' + tagname + '>')
		if tagend > -1:
			return [tagname, tstart, tagend + len(tagname) + 2, 0]
		else:
			tagend = string[tstart:].find('/>')
			if tagend > -1:
				return [tagname, tstart, tstart + tagend + 1, 1]
			else:
				return False
	else:
		return False
string = ''
n = int(input())
for i in range(0, n):
	string += ' ' + input()
cstart = string.find('<!--')
while cstart > -1:
	cend = string[cstart:].find('-->')
	top = string[:cstart]
	tail = string[cstart + cend + 3:]
	string = top + tail
	cstart = string.find('<!--')
tstart = string.find('<')
while tstart > -1 and len(string) > 1:
	string = string[tstart + 1:]
	tstart = string.find('<')
	if string[0] != '/':
		tend = string.find('>')
		nameend = string.find(' ')
		if nameend == -1 or nameend > tend:
			print(string[:tend])
		else:
			print(string[0:nameend])
			propcont = string[nameend:tend]
			pos = propcont.find('=')
			while pos != -1:
				top = propcont[:pos]
				atname = top[top.rfind(' ') + 1:]
				setstart = propcont[pos + 1:].find('"') + pos + 2
				setend = propcont[setstart + 1:].find('"') + setstart
				print('-> ' + atname + ' > ' + propcont[setstart:setend + 1])
				propcont = propcont[setend + 1:]
				pos = propcont.find('=')


import html.parser
import sys

class MyHTMLParser(html.parser.HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (k, v) in attrs:
			print('-> {} > {}'.format(k, v))
input()
p = MyHTMLParser()
p.feed(sys.stdin.read())


from html.parser import HTMLParser
html = ''

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attr):
		print(tag)
		if len(attr):
			for (a, b) in attr:
				print('-> {} > {}'.format(a, b))

	def handle_endtag(self, tag):
		pass

	def handle_startendtag(self, tag, attr):
		print(tag)
		if len(attr):
			for (a, b) in attr:
				print('-> {} > {}'.format(a, b))

	def handle_comment(self, data):
		pass
for i in range(0, int(input())):
	html += input().rstrip()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for att in attrs:
			print('-> %s > %s' % (att[0], att[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for att in attrs:
			print('-> %s > %s' % (att[0], att[1]))
N = int(input())
htmlText = []
for _ in range(N):
	htmlText.append(input())
parser = MyHTMLParser()
parser.feed('\n'.join(htmlText))


import re
flags = re.MULTILINE | re.DOTALL

def parse_attributes(attributes):
	ret = []
	for (a, _, b) in re.findall('([^=\\s]+)(=[\'"]([^\'"]+)[\'"])?', attributes):
		if a != '/':
			ret.append((a, b))
	return ret

def get_tags(text):
	text = re.sub('<!--.*?-->', '', text, flags=flags)
	for (tag, _, attributes) in re.findall('< *([^ >]+)( ([^>]+))?>', text, flags=flags):
		if tag[0] != '/':
			yield (tag, parse_attributes(attributes.strip()))
text = []
for _ in range(int(input())):
	text.append(input())
for (tag_name, attributes) in get_tags('\n'.join(text)):
	print(tag_name)
	for (attr, value) in attributes:
		print('-> {} > {}'.format(attr, value))


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + str(attr[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> ' + attr[0] + ' > ' + str(attr[1]))
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser
from html.entities import name2codepoint

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> {} > {}'.format(attr[0], attr[1]))
n = int(input())
l = list((input() for i in range(n)))
s = ''.join(l)
parser = MyHTMLParser()
parser.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		self._print_attrs(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self._print_attrs(attrs)

	def _print_attrs(self, attrs):
		if attrs:
			for attr in attrs:
				print('->', attr[0], '>', attr[1])
n = int(input())
s = ''
for _ in range(n):
	s += input()
parser = MyHTMLParser()
parser.feed(s)


import re
inp = ''
for i in range(int(input())):
	inp += input().strip()
inp = re.sub('<!--(.*?)-->', '', inp)
for i in re.finditer('<([a-zA-Z][a-zA-Z0-9]*)([^>]*)>', inp):
	print(i.group(1))
	for j in re.finditer('([a-zA-Z][^=]*)="([^"]+)"', i.group(2)):
		print('->', j.group(1), '>', j.group(2))


from html.parser import HTMLParser

class h(HTMLParser):

	def handle_starttag(self, t, a):
		print(t)
		for (x, y) in a:
			print('->', x, '>', y)

	def handle_startendtag(self, t, a):
		print(t)
		for (x, y) in a:
			print('->', x, '>', y)
p = h()
I = [input() for _ in range(int(input()))]
for x in I:
	p.feed(x)


from html.parser import HTMLParser

class myHTMLParser(HTMLParser):

	def handle_comment(self, data):
		pass

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('->', ' > '.join(a))
html = ''
for _ in range(int(input())):
	html += input() + '\n'
parser = myHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_comment(self, data):
		return data

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> ', end='')
			print(*a, sep=' > ')
ls = []
for _ in range(int(input())):
	ls.append(input())
ls = ''.join(ls)
parser = MyHTMLParser()
parser.feed(ls)


lokal = 0
if lokal:
	f = open('in.txt')
	inFkt = f.readline
else:
	inFkt = input
import os, re
N = int(inFkt())
txt = ''
for n in range(0, N):
	txt += inFkt()
txt = txt.replace('\n', ' ')
comR = '<\\!--.*?-->'
txt = re.sub(comR, '', txt)
tagR = '<([a-zA-Z0-9]*)( [^>]*)?>'
tags = re.findall(tagR, txt)
attR = '([a-zA-Z0-9\\-]*)="([^"]*)"'
for t in tags:
	print(t[0])
	if len(t[1]) > 0:
		atts = re.findall(attR, t[1])
		for a in atts:
			print('-> ' + a[0] + ' > ' + a[1])


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		self.print_attrs(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self.print_attrs(attrs)

	def print_attrs(self, attrs):
		for i in attrs:
			print('-> ' + i[0] + ' > ' + str(i[1]))
parser = MyHTMLParser()
string = ''
for i in range(int(input())):
	string += input()
	string += '\n'
parser.feed(string)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])
html = ''
for _ in range(int(input())):
	html += input()
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser
from html.entities import name2codepoint

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('->', attr[0], '>', attr[1])

	def handle_endtag(self, tag):
		pass

	def handle_data(self, data):
		pass

	def handle_comment(self, data):
		pass

	def handle_entityref(self, name):
		pass

	def handle_charref(self, name):
		pass

	def handle_decl(self, data):
		pass
parser = MyHTMLParser()
lines = int(input())
for _ in range(lines):
	parser.feed(input())


from html.parser import HTMLParser
num = int(input())

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (x, y) in attrs:
			print('->', x, '>', y)
parser = MyHTMLParser()
for x in range(num):
	parser.feed(input())


s = ''
for _ in range(int(input())):
	s += input()
from html.parser import HTMLParser
import urllib

class parseTitle(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for (name, value) in attrs:
			print('-> ' + name + ' > ' + value)
aparser = parseTitle()
aparser.feed(s)


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> %s > %s' % attr)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			print('-> %s > %s' % attr)
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('->', a[0], '>', a[1])
MyHTMLParser().feed(''.join([input() for _ in range(int(input()))]))


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for at in attrs:
			print('-> {} > {}'.format(at[0], at[1]))

	def handle_startendtag(self, tag, attrs):
		print(tag)
		for at in attrs:
			print('-> {} > {}'.format(at[0], at[1]))
html = ''
for i in range(int(input())):
	html += input().rstrip()
	html += '\n'
parser = MyHTMLParser()
parser.feed(html)
parser.close()


from html.parser import HTMLParser

class Parser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for attr in attrs:
			(prop, value) = attr
			print('-> ' + prop + ' > ' + value)
N = int(input())
s = ''
for i in range(N):
	s += ' ' + input()
parser = Parser()
parser.feed(s)


from sys import stdin
from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handle_starttag(self, tag, attrs):
		print(tag)
		for a in attrs:
			print('-> {} > {}'.format(*a))
n = int(stdin.readline().strip())
parser = MyHTMLParser()
parser.feed(stdin.read())
parser.close()


from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):

	def handleAttrs(self, attrs):
		for (x, y) in attrs:
			if y != None:
				print('-> {} > {}'.format(x, y))
			else:
				print('-> {}'.format(x))

	def handle_starttag(self, tag, attrs):
		print(tag)
		self.handleAttrs(attrs)

	def handle_startendtag(self, tag, attrs):
		print(tag)
		self.handleAttrs(attrs)
parser = MyHTMLParser()
txt = ''
for _ in range(int(input())):
	txt += input().strip()
parser.feed(txt)