#ARC145A. [ARC145A] AB Palindrome

[ARC145A] AB Palindrome

Score : 400400 points

Problem Statement

You are given a string SS of length NN consisting of A and B.

You can repeat the following operation zero or more times:

  • choose a pair of adjacent characters in SS and replace them with AB.

Determine whether SS can be turned into a palindrome.

What is a palindrome? T$$$$i$$$$1 \le i \le |T|$$$$i$$$$i$$$$|T|$$$$T

Constraints

  • 2N2×1052 \leq N \leq 2\times 10^5
  • SS is a string of length NN consisting of A and B.

Input

Input is given from Standard Input in the following format:

NN

SS

Output

If SS can be turned into a palindrome, print Yes; otherwise, print No.

3
BBA
Yes

Replacing the 22-nd and 33-rd characters, BA, with AB will turn SS into BAB, a palindrome.

4
ABAB
No

No sequence of operations can turn SS into a palindrome.