Description

Jazmin has a garden in front of her house, with \$N\$ plants forming a line in the left-right direction. She is very proud of her plants, and measures their growing heights with great precision, because she thinks that each plant is different and so it must have a different height.

One day Jazmin found a grasshopper in her garden, and after watching it for some time, she noticed a very peculiar behavior. During each jump the grasshopper moves to the  first plant taller than its current plant, in the direction it is looking at. Besides, before landing on the new plant, the grasshopper does a back ip that changes its direction. That is, if before jumping the grasshopper is looking to the left, once the jump is completed it is looking to the right, and vice versa. The grasshopper keeps jumping until there is no taller plant in the direction it is looking at.

Jazmin decided to record her sightings of the grasshopper. Each time she saw it, she wrote the plant where the grasshopper was, and the direction it was looking at. She also recorded how her plants were growing, as she always does. Now Jazmin wonders, for each sighting of the grasshopper, on which plant it stopped jumping. Jazmin's notebook is currently broken, so she cannot write her own program. Can you help her?

Input

The  first line contains two integers \$N\$ and \$M\$ (\$1 \leq N,M \leq 2\times 10^5\$), indicating respectively the number of plants and the number of records. Plants are identified by distinct integers from 1 to \$N\$ according to their positions in front of the house, starting from the leftmost plant. The second line contains \$N\$ different integers \$H_1, H_2,\ldots, H_N (0 \leq H_i \leq 10^9\$ for \$i = 1, 2,\ldots,N)\$, where \$H_i\$ is the initial height of plant \$i\$. The following \$M\$ lines describe Jazmin's records in chronological order, one line per record. If a record represents the growing of a plant, the line contains the uppercase letter "U" followed by two integers \$I (1 \leq I \leq N)\$ and \$H (H \leq 10^9)\$, indicating that the new height of plant \$I\$ is \$H\$; the new height \$H\$ is greater than the old height of plant \$I\$, and different from the current height of each of the other plants. If a record represents the sighting of the grasshopper, the line contains the uppercase letter "L" or th uppercase letter "R" followed by an integer \$J (1 \leq J \leq N)\$ indicating that the grasshopper starts jumping from plant \$J\$; the grasshopper starts looking to the left if the letter is "L", and it starts looking to the right if the letter is "R". There is at least one record that is a sighting of the grasshopper.

Output

Output a line for each sighting of the grasshopper. The line must contain an integer indicating the plant where the grasshopper stops jumping. Write the results in chronological order, that is, using the same order of the input.

Samples

Input Copy
10 4
1 8 5 6 10 20 12 15 2 4
L 2
R 3
U 10 16
L 9
Output
2
5
6

Source

ICPC Latin American Regional 2019
Problem Information

 Time Limit: 3000MS (C/C++,Others×2) Memory Limit: 64MB (C/C++,Others×2) Special Judge: No AC/Submit: 2 / 2 Tags:
Contests involved

 1039. ICPC Latin American Regional 2019