This challenge works with a custom-designed markup language HRML. In HRML, each element consists of a starting and ending tag, and there are attributes associated with each tag. Only starting tags can have attributes. We can call an attribute by referencing the tag, followed by a tilde, '~' and the name of the attribute. The tags may also be nested.
Given the source code in HRML format consisting of lines, answer queries. For each query, print the value of the attribute specified. Print "Not Found!" if the attribute does not exist.
<tag1 value = "value">
<tag2 name = "name">
<tag3 another="another" final="final">
Here, tag2 is nested within tag1, so attributes of tag2 are accessed as tag1.tag2~<attribute>. Results of the queries are:
tag1.tag2.tag3~name "Not Found!"
The first line consists of two space separated integers, and . specifies the number of lines in the HRML source program. specifies the number of queries.
The following lines consist of either an opening tag with zero or more attributes or a closing tag. There is a space after the tag-name, attribute-name, '=' and value.There is no space after the last value. If there are no attributes there is no space after tag name.
queries follow. Each query consists of string that references an attribute in the source program.More formally, each query is of the form ~ where and are valid tags in the input.
Each line in the source program contains, at most, characters.
Every reference to the attributes in the queries contains at most characters.
All tag names are unique and the HRML source program is logically correct, i.e. valid nesting.
A tag can may have no attributes.
Print the value of the attribute for each query. Print "Not Found!" without quotes if the attribute does not exist.
<tag1 value = "HelloWorld">
<tag2 name = "Name1">