Collider
InterviewTime limit2sMemory limit256 MB
Move the particle at position i to position j on each exposure and report the particle type at position k for each query.
- Level
Easy3 of 10
- Topics
- Array, Simulation
- Solved
- No attempts yet
Problem
Physicists study particles of three types: x, y and z. They load a row of numbered particles into a collider. During the experiment a beam is aimed at one particle. The exposed particle disappears from position of the row and instantly reappears at position . When it disappears, the numbers of the particles to its right drop by 1. When it reappears, the numbers of the particles to the right of the new place rise by 1. After some exposures the scientists want to know which particle sits at position . Write a program that answers them.
Input
The first line contains two integers, the number of particles and the combined number of exposures and queries (, ).
The second line contains a string of length built from the characters x, y and z.
Each of the next lines describes one exposure or one query. A line describing an exposure starts with the character a and a space, followed by two integers from the range . The first integer is the start position of the exposed particle and the second is its finish position. A line describing a query starts with the character q and a space, followed by one integer from the range , the position the scientists ask about.
Output
Print one line for every query, in the order the queries appear in the input. Line holds the answer to query , the name of the particle at that position: x, y or z.
Note
An exposure a happens in two steps. First the particle at position leaves the row, which then holds particles. Then that particle is put back so that it occupies exactly position in the row of particles that results. If equals , the row does not change. For example, if the row is xyzz and the exposure is a 1 3, taking x out leaves yzz, and putting it back gives yzxz.