In fact, since yesterday brush, preparing for what PAT (B, chicken dishes do not explain, I hope a few months can grow in it), do a bit and found his poor arithmetic skills good ah. . . . .
First on the subject
1. The string must only P, A, T three character, other characters can not contain;
2 xPATx arbitrary shape such as a string can get "correct answer", or where x is an empty string, or a string is composed only of letters;
3. If aPbTc is correct, then aPbATca is correct, wherein a, b, c or all the empty string, or a string consisting only of letters a.
Now ask you to write a PAT referee program automatically determines which strings can get "the answer right".
Input format: Each test comprises a test input. Line 1 shows a natural number n (<10), is the number of strings to be detected. Next, one row for each string, the string length of not more than 100, no spaces.
Output formats: the detection result row for each string, if the string can get "correct answer", the output YES, otherwise output NO.
Sample input:
8
PAT
PAAT
AAPATAA
AAPAATAAAA
xPATx
PT
Whatever
APAAATAA
Sample output:
YES YES YES YES NO NO NO NO
Again on my code
Good food ah, checked the others, get 28 rows. . . . . .