atcoder#AGC011D. [AGC011D] Half Reflector

[AGC011D] Half Reflector

Score : 900900 points

Problem Statement

Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows:

  • When a device in state A receives a ball from either side (left or right), the device throws out the ball from the same side, then immediately goes into state B.
  • When a device in state B receives a ball from either side, the device throws out the ball from the other side, then immediately goes into state A.

The transition of the state of a device happens momentarily and always completes before it receives another ball.

Takahashi built a contraption by concatenating NN of these devices. In this contraption,

  • A ball that was thrown out from the right side of the ii-th device from the left (1iN11 \leq i \leq N-1) immediately enters the (i+1)(i+1)-th device from the left side.
  • A ball that was thrown out from the left side of the ii-th device from the left (2iN2 \leq i \leq N) immediately enters the (i1)(i-1)-th device from the right side.

The initial state of the ii-th device from the left is represented by the ii-th character in a string SS. From this situation, Takahashi performed the following KK times: put a ball into the leftmost device from the left side, then wait until the ball comes out of the contraption from either end. Here, it can be proved that the ball always comes out of the contraption after a finite time. Find the state of each device after KK balls are processed.

Constraints

  • 1N200,0001 \leq N \leq 200,000
  • 1K1091 \leq K \leq 10^9
  • S=N|S|=N
  • Each character in SS is either A or B.

Input

The input is given from Standard Input in the following format:

NN KK

SS

Output

Print a string that represents the state of each device after KK balls are processed. The string must be NN characters long, and the ii-th character must correspond to the state of the ii-th device from the left.

5 1
ABAAA
BBAAA

In this input, we put a ball into the leftmost device from the left side, then it is returned from the same place.

5 2
ABAAA
ABBBA
4 123456789
AABB
BABA