Subin was surprised to learn that some English words use only the letters A and B. AB (short for Abdominal), BAA (the sound a sheep makes), AA (a type of lava), and ABBA (the Swedish pop group) are examples.
Starting from that idea, Subin made a simple game. Given two strings S and T, the goal is to turn S into T. Only these two operations can change a string.
- Append A to the end of the string.
- Reverse the string, then append B to the end.
Write a program that decides whether these operations can turn S into T.