Problem Statement
You are given a string $S$ of length $N$ consisting of A, B, C.
You can do the following two kinds of operations on $S$ any number of times in any order.
- Choose
Ain$S$, delete it, and insertBBat that position. - Choose two adjacent characters that are
BBin$S$, delete them, and insertAat that position.
Find the lexicographically smallest possible string that $S$ can become after your operations.
What is the lexicographical order? Simply speaking, the lexicographical order is the order in which words are listed in a dictionary. As a more formal definition, here is the algorithm to determine the lexicographical order between different strings $S$ and $T$. Below, let $S_i$ denote the $i$-th character of $S$. Also, if $S$ is lexicographically smaller than $T$, we will denote that fact as $S \lt T$; if $S$ is lexicographically larger than $T$, we will denote that fact as $S \gt T$. Let $L$ be the smaller of the lengths of $S$ and $T$. For each $i=1,2,\dots,L$, we check whether $S_i$ and $T_i$ are the same. If there is an $i$ such that $S_i \neq T_i$, let $j$ be the smallest such $i$. Then, we compare $S_j$ and $T_j$. If $S_j$ comes earlier than $T_j$ in alphabetical order, we determine that $S \lt T$ and quit; if $S_j$ comes later than $T_j$, we determine that $S \gt T$ and quit. If there is no $i$ such that $S_i \neq T_i$, we compare the lengths of $S$ and $T$. If $S$ is shorter than $T$, we determine that $S \lt T$ and quit; if $S$ is longer than $T$, we determine that $S \gt T$ and quit.
Constraints
$1 \leq N \leq 200000$$S$is a string of length$N$consisting ofA,B,C.
Input
Input is given from Standard Input in the following format:
N
S
Output
Print the answer.
样例
4
CBAA
CAAB
1
A
A
6
BBBCBB
ABCA
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。