String Converter
String Transformer is a unique program designed to take a string as input and produce a transformed string as output. This transformation involves applying two types of operations to specific substrings of the input string:
**Reversal (denoted by R)**: This operation reverses the order of characters in a substring. For example, given a substring S_1S_2...S_n-1S_n, the result will be S_nS_n-1...S_2S_1.
**Sorting (denoted by S)**: This operation sorts the characters in a substring in non-decreasing order based on their alphabetical indices. For instance, the substring hello would be transformed into ehllo.
You are provided with 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 composed solely of lowercase Latin letters. The length of this string, m, does not exceed 200 characters. The second line contains the number of operations, n (1 ≤ n ≤ 200).
Each of the next n lines describes one operation in the format OP L R, where OP is the operation symbol, L is the starting position of the substring, and R is the ending position (1 ≤ L ≤ R ≤ m). If the string before the operation is S_1S_2...S_m, then after the operation, it becomes S_1...S_L-1OP(S_L...S_R)S_R+1...S_m, where OP(S_L...S_R) is the result of applying the specified operation to the substring S_L...S_R.
Output
Output the final string after all operations specified in the input have been applied to the initial string.