100 atcoder#ABC199C. [ABC199C] IPFL
[ABC199C] IPFL
Score : points
Problem Statement
We have a string of length . You are given queries on this string. In the -th query, given three integers , , and , do the following:
- if : swap the -th and -th characters of ;
- if : swap the first characters and last characters of (the values and are not used).
For example, if is
FLIP
, this query makes itIPFL
.
Print the string after processing all queries in the order they are given.
Constraints
- is a string of length consisting of uppercase English letters.
- is or .
- If , .
- If , .
Input
Input is given from Standard Input in the following format:
Output
Print the string after processing the queries.
2
FLIP
2
2 0 0
1 1 4
LPFI
The -st query swaps the first characters and last characters of , making it IPFL
.
The -nd query swaps the -st and -th characters of , making it LPFI
.
2
FLIP
6
1 1 3
2 0 0
1 1 2
1 2 3
2 0 0
1 1 4
ILPF