atcoder#ABC258C. [ABC258C] Rotation
[ABC258C] Rotation
Score : points
Problem Statement
You are given positive integers and , and a string of length consisting of lowercase English letters.
Process queries. Each query is of one of the following two types.
1 x
: Perform the following times in a row: delete the last character of and append it to the beginning.2 x
: Print the -th character of .
Constraints
- consists of lowercase English letters.
- At least one query in the format
2 x
. - , , are all integers.
Input
Input is given from Standard Input in the following format:
Each query is in the following format, where is or :
Output
For each query in the format 2 x
, print the answer in a single line.
3 3
abc
2 2
1 1
2 2
b
a
In the -st query, is abc
, so the -nd character b
should be printed.
In the -nd query, is changed from abc
to cab
.
In the -rd query, is cab
, so the -nd character a
should be printed.
10 8
dsuccxulnl
2 4
2 7
1 2
2 7
1 1
1 2
1 3
2 5
c
u
c
u