100 atcoder#ABC199C. [ABC199C] IPFL

[ABC199C] IPFL

Score : 300300 points

Problem Statement

We have a string SS of length 2N2N. You are given QQ queries on this string. In the ii-th query, given three integers TiT_i, AiA_i, and BiB_i, do the following:

  • if Ti=1T_i = 1: swap the AiA_i-th and BiB_i-th characters of SS;
  • if Ti=2T_i = 2: swap the first NN characters and last NN characters of SS (the values AiA_i and BiB_i are not used). For example, if SS is FLIP, this query makes it IPFL.

Print the string SS after processing all QQ queries in the order they are given.

Constraints

  • 1N2×1051 \le N \le 2 \times 10^5
  • SS is a string of length 2N2N consisting of uppercase English letters.
  • 1Q3×1051 \le Q \le 3 \times 10^5
  • TiT_i is 11 or 22.
  • If Ti=1T_i = 1, 1Ai<Bi2N1 \le A_i \lt B_i \le 2N.
  • If Ti=2T_i = 2, Ai=Bi=0A_i = B_i = 0.

Input

Input is given from Standard Input in the following format:

NN

SS

QQ

T1T_1 A1A_1 B1B_1

T2T_2 A2A_2 B2B_2

T3T_3 A3A_3 B3B_3

\hspace{21pt} \vdots

TQT_Q AQA_Q BQB_Q

Output

Print the string SS after processing the queries.

2
FLIP
2
2 0 0
1 1 4
LPFI

The 11-st query swaps the first NN characters and last NN characters of SS, making it IPFL. The 22-nd query swaps the 11-st and 44-th characters of SS, 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