#abc242d. [abc242_d]ABC Transform
[abc242_d]ABC Transform
Problem Statement
You are given a string consisting of A
, B
, C
.
Let . For , let be the result of simultaneously replacing the characters of as follows: A
→ BC
, B
→ CA
, C
→ AB
.
Answer queries. The -th query is as follows.
- Print the -th character from the beginning of .
Constraints
- is a string of length between and (inclusive) consisting of
A
,B
,C
. - the length of
- are integers.
Input
Input is given from Standard Input in the following format:
Output
Process the queries in ascending order of index, that is, in the given order. Each answer should be followed by a newline.
Sample Input 1
ABC
4
0 1
1 1
1 3
1 6
Sample Output 1
A
B
C
B
We have ABC
, BCCAAB
.
Thus, the answers to the queries are A
, B
, C
, B
in the given order.
Sample Input 2
CBBAACCCCC
5
57530144230160008 659279164847814847
29622990657296329 861239705300265164
509705228051901259 994708708957785197
176678501072691541 655134104344481648
827291290937314275 407121144297426665
Sample Output 2
A
A
C
A
A