14901 - It Is Very Simple   

Description

It's a very simple problem.

You are given an initial mysterious string and q queries.

The mysterious string is given in the format d1|d2|...|dm, where each di is a decimal integer.

Initialization:

  1. Convert each decimal integer di into its exact hexadecimal string representation.   (e.g., 20065|16019311|33981975|40140414 -> 4E61|F46F6F|2068617|2647E7E)

  2. Concatenate them sequentially to form a single continuous hexadecimal character string S.   (e.g., 4E61|F46F6F|2068617|2647E7E -> 4E61F46F6F20686172647E7E)

Queries:

Each query will be one of the following two operations, operating strictly on the hexadecimal characters (every idx is 0-based):

  • Insert idx str:

    First, decode the str (given in the same di format) into a hexadecimal string SInsert using the Initialization rules. Then, insert SInsert into S at idx.

  • Remove idx len:

    Delete exactly len characters from S, starting from idx. (remove characters from idx to idx + len - 1).

 

Input

The first line contains a single string, representing the initial mysterious string in the format d1|d2|...|dm.

The second line contains an integer q, representing the number of queries.

The following lines describe the q queries.

Constraints:

  • 1 <= q <= 100

  • di is an integer.

  • 0 <= idx <= idx + len - 1 <= len(S)

  • The length of string S and any mysterious string is guaranteed to never exceed 10000 characters at any given time.

Output

Output the final decoded ASCII string on a single line after processing all queries.

(Note: Every consecutive pair of hexadecimal digits maps to exactly one ASCII character. For example, 4E6F decodes to No.)

Remember to add '\n' at the end of a line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss