Jeremy really likes the Swedish rock band ABBA. So much so, he is obsessed with strings consisting of the letters A
and B
. He has 2 strings A
or B
for its letters, and A
to the end of the string. The second operation reverses the string, and then adds a B
to the end of the string. He wonders if there is a sequence of operations to transform
Input Specification
The first line will be the integer
Output Specification
YES
if there is NO
otherwise.
Sample Input 1
3
ABBA
ABBAAAA
AB
BABA
A
B
Sample Output 1
YES
YES
NO
Comments