This page is still under construction.

Parts of this page are still being built. What you see may change.

Damaged XML

Time limit2sMemory limit1024 MB

Summary
Given an XML-like string corrupted by exactly one character replacement, find any correct XML string obtainable by changing exactly one character.
Level

Medium7 of 10

Topics
String, Stack, Greedy, Implementation
Solved
No attempts yet

Problem

XML is a common format for exchanging data between different programs. Programmer Ivanov recently wrote a small program that saves some important information as an XML string.

An XML string consists of opening and closing tags.

An opening tag starts with an opening angle bracket (<), followed by the tag name, a nonempty string of lowercase Latin letters, and then a closing angle bracket (>). Examples of opening tags are <a> and <dog>.

A closing tag starts with an opening angle bracket, followed by a forward slash (/), then the tag name, a nonempty string of lowercase Latin letters, and then a closing angle bracket. Examples of closing tags are </a> and </dog>.

An XML string is correct if it can be produced by the following rules:

  • The empty string is a correct XML string.
  • If A and B are correct XML strings, then the string AB, obtained by appending B to the end of A, is also a correct XML string.
  • If A is a correct XML string, then the string <X>A</X>, obtained by prepending an opening tag to A and appending a closing tag with the same name, is also a correct XML string. Here X is any nonempty string of lowercase Latin letters.

For example, the following strings:

<a></a>
<a><ab></ab><c></c></a>
<a></a><a></a><a></a>

are correct XML strings, while these strings:

<a></b>
<a><b>
<a><b></a></b>

are not correct XML strings.

Ivanov sent the file with the saved XML string by email to his colleague Petrov. Unfortunately, the file was damaged during transmission: exactly one character in the string was replaced by some other character.

You must write a program that, given the string Petrov received, restores the original XML string that Ivanov sent.

Input

The input file contains one string that can be turned into a correct XML string by replacing exactly one character. The length of the string is between 7 and 1000, inclusive. The string contains only lowercase Latin letters and the characters < (ASCII code 60), > (ASCII code 62), and / (ASCII code 47).

The string in the input file ends with a newline.

Output

The output file must contain a correct XML string that can be obtained from the string in the input file by replacing exactly one character with another. If there are several answers, you may output any of them.

Examples4

  1. Example 1

    Input
    <a></b>
    
    Expected output
    <a></a>
    
  2. Example 2

    Input
    <a><aa>
    
    Expected output
    <a></a>
    
  3. Example 3

    Input
    <a><>a>
    
    Expected output
    <a></a>
    
  4. Example 4

    Input
    <a/</a>
    
    Expected output
    <a></a>