{"problem":{"name":"Half Reflector","description":{"content":"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 follow","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc011_d"},"statements":[{"statement_type":"Markdown","content":"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:\n\n*   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.\n*   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.\n\nThe transition of the state of a device happens momentarily and always completes before it receives another ball.\nTakahashi built a contraption by concatenating $N$ of these devices. In this contraption,\n\n*   A ball that was thrown out from the right side of the $i$\\-th device from the left ($1 \\leq i \\leq N-1$) immediately enters the $(i+1)$\\-th device from the left side.\n*   A ball that was thrown out from the left side of the $i$\\-th device from the left ($2 \\leq i \\leq N$) immediately enters the $(i-1)$\\-th device from the right side.\n\nThe initial state of the $i$\\-th device from the left is represented by the $i$\\-th character in a string $S$. From this situation, Takahashi performed the following $K$ 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 $K$ balls are processed.\n\n## Constraints\n\n*   $1 \\leq N \\leq 200,000$\n*   $1 \\leq K \\leq 10^9$\n*   $|S|=N$\n*   Each character in $S$ is either `A` or `B`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc011_d","tags":[],"sample_group":[["5 1\nABAAA","BBAAA\n\nIn this input, we put a ball into the leftmost device from the left side, then it is returned from the same place."],["5 2\nABAAA","ABBBA"],["4 123456789\nAABB","BABA"]],"created_at":"2026-03-03 11:01:13"}}