atcoder#ABC242D. [ABC242D] ABC Transform
[ABC242D] ABC Transform
Score : points
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.
ABC
4
0 1
1 1
1 3
1 6
A
B
C
B
We have ABC
, BCCAAB
.
Thus, the answers to the queries are A
, B
, C
, B
in the given order.
CBBAACCCCC
5
57530144230160008 659279164847814847
29622990657296329 861239705300265164
509705228051901259 994708708957785197
176678501072691541 655134104344481648
827291290937314275 407121144297426665
A
A
C
A
A