atcoder#AGC062A. [AGC062A] Right Side Character
[AGC062A] Right Side Character
Score : points
Problem Statement
For a string of length consisting of A
and B
, we define a string of length as follows.
- Let be the indices such that
A
, and be the indices such thatB
. Then, let $f(T)=T_{a_1+1}T_{a_2+1}\dots T_{a_m+1}T_{b_1+1}T_{b_2+1}\dots T_{b_k+1}$.
For example, for the string ABBABA
, the indices with A
are , and the indices with B
are , so is BBBAA
.
You are given a string of length consisting of A
and B
.
Find after replacing with times.
You have test cases to solve.
Constraints
- is a string of length consisting of
A
andB
. - All numbers in the input are integers.
- The sum of over the test cases in a single input file is at most .
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Output
Print lines. The -th line should contain the answer to the -th test case.
3
2
AB
3
AAA
4
ABAB
B
A
A
In the first test case, changes as AB
B
.
In the second test case, changes as AAA
AA
A
.
In the third test case, changes as ABAB
BBA
BA
A
.