Cake

No attempts yetTime limit2sMemory limit1024 MB

Problem

Leopold and Molly both love cake. Leopold loves eating it, and Molly loves watching Leopold eat it. Today they bought NN pieces of seed cake. The pieces lie in a row on a narrow plate that has NN positions. The positions are numbered 11 to NN from left to right, and piece ii lies on position ii.

Leopold cares about how delicious the pieces are. The initial deliciousness of piece ii is did_i. He starts with piece aa, which leaves position aa empty. After that he always eats the least delicious piece next to an empty position, so the empty positions always form one closed interval. Molly sometimes puts a topping on a piece to make it more delicious. She always does so in a way that makes the piece one of the 10 most delicious pieces. No two pieces are equally delicious at any time.

Molly sometimes wonders how many pieces Leopold eats before he eats piece bb, assuming she adds no further toppings. Write a program that processes instructions of two kinds: make a piece more delicious, and report how many pieces Leopold eats before a given piece.

A query does not actually consume any cake. Each query considers the eating process started again from piece aa with the deliciousness values as they stand at that moment.

Input

The first line contains the number of pieces NN (1N2500001 \le N \le 250\,000) and the piece aa (1aN1 \le a \le N) that Leopold eats first. The second line contains the initial deliciousness values d1,,dNd_1, \dots, d_N. They are pairwise distinct and satisfy 1diN1 \le d_i \le N. The third line contains the number of instructions QQ (1Q5000001 \le Q \le 500\,000). Each of the next QQ lines contains one instruction of one of the two kinds below.

  • E i e (the character E followed by two integers 1iN1 \le i \le N and 1e101 \le e \le 10): piece ii is enhanced so that it becomes the ee-th most delicious piece. The deliciousness order of the other pieces does not change. Before the enhancement, at least ee pieces are more delicious than piece ii.
  • F b (the character F followed by an integer 1bN1 \le b \le N): report how many pieces Leopold eats before he eats piece bb.

Output

For each F instruction, in the order the instructions appear in the input, print one line with a single integer: the requested number of pieces.

Limits

  • N250000N \le 250\,000, Q500000Q \le 500\,000