String Transformer#2196

String Transformer

1 second
64 megabytes
Very easy

String Transformer is a unique program designed to take an input string and produce a transformed string as output. This transformation involves applying two types of operations to specific substrings of the input string:

You are given a string and a sequence of operations to perform on its substrings. Your task is to determine the final result after applying all these operations.

Input

The first line of the input contains the initial string, which is non-empty and consists only of lowercase Latin letters. The length of this string does not exceed . The second line contains the number of operations , where 1 \leq n \leq 200.

Each of the next lines describes a single operation in the format OP\ L\ R, where is the operation symbol, is the starting position of the substring, and is the ending position (1 \leq L \leq R \leq m). If the string before the operation is S_1 S_2 \ldots S_m, then after the operation it becomes S_1 \ldots S_{L-1}\ OP(S_L \ldots S_R)\ S_{R+1} \ldots S_m, where OP(S_L \ldots S_R) is the result of applying the specified operation to the substring S_L \ldots S_R.

Output

Print the final string after applying all the operations described in the input to the initial string.

Examples

Example 1

Loading
Loading