By TopCoder* USA
You are in command of a document system that uses tags numeric code to render documents for printing. There are a lot of documents with text based tags, you must analyze and convert to numeric tags for entry into the system. A tag is initiated by a character '<', which may be followed by letters, numbers, spaces or bars, and the tag to complete a character '>'. The tags can not be nested into each other.
The following tags are not valid:
">HI", "<a<b>c>", "<a b c><", "<a<b>".
The following tags are valid:
"/=<>HI", "/<>H=I<>/", "<><><><>", "<a=/><b==//bb><c223>", "<a b c>".
For comparisons between the characters should be disregarded case sensitive.
There is many test cases. Each test case consist of three lines. The first line contains the original tag in the text of this document, which will only contain letters (a-z, A-Z), and its size will be between 1 and 10 characters inclusive. The second line contains the tag number by which the original tag is to be replaced, which is a number between 1 and 1000 inclusive. The third and last line will be between 1 and 50 characters inclusive, and may contain letters (a-z, A-Z), numbers (0-9), less-than sign (<), greater-than sign (>), signs equals (=), bars (/), or blanks. All '<' and '>' are only used in tags.
Convert the text of the document is given in the input, using to specifications given above and print in a single line, the new text document with the new tags, for more information see the example below.
Sample Input | Sample Output |
BODY |
<><10 garbage>body</10> |