14199 - CS website part 3   

Description

In this problem, you have to implement a website editor by combining 13573 - CS website part 1 and 13574 - CS website part 2.

 

First, you have to read a html code.

It is guaranteed that the format of the html code must satisfy:

<html>
   <head>
      <title>{THE CONTENT OF THE TITLE}</title>
   </head>
   <body>
      <{TAG}>{THE CONTENT OF THE BODY}</{TAG}>

      ......

      <{TAG}>{THE CONTENT OF THE BODY}</{TAG}>
   </body>
</html>

(The number of spaces are 3 and 6 separately)

TAG may be h1 or p here and it is guaranteed that there are no nested structures (only one tag type in each line).

For example:

<html>
   <head>
      <title>Good Luck!</title>
   </head>
   <body>
      <h1>Have Fun! 0</h1>
      <p>Have Fun! 1</p>
      <h1>Have Fun! 2</h1>
      <p>Have Fun! 3</p>
   </body>
</html>

After you read the html code, you'll get an initial title and arbitrary amounts of content.

In the following steps, you can treat the contents of the h1 and p tags as the two groups of tables in 13574 - CS website part 2.

The order of the contents is calculated separately.

For example, the content of the 0th table in h1 tags is "Have Fun! 0"; the content of the 1st table in h1 tags is "Have Fun! 2".

The content of the 0th table in p tags is "Have Fun! 1"; the content of the 1st table in p tags is "Have Fun! 3".

 

Based on the rule in 13574 - CS website part 2, given a command S, you have to follow the instructions below:

The difference between this problem and 13574 - CS website part 2 is that you have to choose which group of tables is going to be operated according to TAG(H1 or P).

(1) print: print the current html code using the predefined format. Since we'll only modify the contents in the tag, the order of the different types of tags in the body should be the same(e.g., h1->p->h1->p in the previous example). 

Note that if the content is cleared, the content will be represented in "No Contents".

(2) all{TAG} c len :  Place len chars on each table in TAG, and the value is c .

For example, the instruction "allH1 m 4" changes the contents of each table in h1 to "mmmm";

(3)

place{TAG} table_idx

STRING

: Place a string STRING on table table_idx.

For example, the instruction will be like:

placeP 2

Hello

And the content of Table_2 in p will become "Hello".

Note that the original contents will be overridden.

(4) swap{TAG} table_a table_b: Swap the cards on table_a and table_b in TAG.

For example:

If the origin html code is:

<html>
   <head>
      <title>Good Luck!</title>
   </head>
   <body>
      <h1>Have Fun! 0</h1>
      <p>Have Fun! 1</p>
      <h1>Have Fun! 2</h1>
      <p>Have Fun! 3</p>
   </body>
</html>

after "swapH1 0 1", the html code becomes:

<html>
   <head>
      <title>Good Luck!</title>
   </head>
   <body>
      <h1>Have Fun! 2</h1>
      <p>Have Fun! 1</p>
      <h1>Have Fun! 0</h1>
      <p>Have Fun! 3</p>
   </body>
</html>

This instruction is valid even if one of the contents is empty.

(5) clear: Clean all the tables in both h1 and p.

(6) exit: terminates

(7) shiftleft{TAG}: Move the contents on each table in TAG to its left. For table 0, move the contents to the last table in TAG.

(8) shiftright{TAG}: Move the contents on each table in TAG to its right. For the last table, move the contents to the table 0 in TAG.

(9)

Newtitle

STRING

: Replace the title with a string STRING.

Input

The input is composed of two parts.

The first part is the initial html code.

The second part is the instruction sets.

Note that:

The maximum length of each content or title should be less than 10001.

The number of h1 and p is less than 100, respectively.

Output

The modified html code.

Sample Input  Download

Sample Output  Download

Tags




Discuss