atcoder#ABC297B. [ABC297B] chess960

[ABC297B] chess960

Score : 200200 points

Problem Statement

Takahashi is playing a game called Chess960. He has decided to write a code that determines if a random initial state satisfies the conditions of Chess960.

You are given a string SS of length eight. SS has exactly one K and Q, and exactly two R's, B's , and N's. Determine if SS satisfies all of the following conditions.

  • Suppose that the xx-th and yy-th (x<y)(x < y) characters from the left of SS are B; then, xx and yy have different parities.
  • K is between two R's. More formally, suppose that the xx-th and yy-th (x<y)(x < y) characters from the left of SS are R and the zz-th is K; then x<z<yx< z < y.

Constraints

  • SS is a string of length 88 that contains exactly one K and Q, and exactly two R's, B's , and N's.

Input

The input is given from Standard Input in the following format:

SS

Output

Print Yes if SS satisfies the conditions; print No otherwise.

RNBQKBNR
Yes

The 33-rd and 66-th characters are B, and 33 and 66 have different parities. Also, K is between the two R's. Thus, the conditions are fulfilled.

KRRBBNNQ
No

K is not between the two R's.

BRKRBQNN
No