Problem

Source: All-Russian MO 2023 Final stage 9.2

Tags: combinatorics



Initially, a word of $250$ letters with $125$ letters $A$ and $125$ letters $B$ is written on a blackboard. In each operation, we may choose a contiguous string of any length with equal number of letters $A$ and equal number of letters $B$, reverse those letters and then swap each $B$ with $A$ and each $A$ with $B$ (Example: $ABABBA$ after the operation becomes $BAABAB$). Decide if it possible to choose initial word, so that after some operations, it will become the same as the first word, but in reverse order.