#P1620A. Equal or Not Equal
Equal or Not Equal
Description
You had positive integers arranged in a circle. For each pair of neighboring numbers ( and , and , ..., and , and and ), you wrote down: are the numbers in the pair equal or not.
Unfortunately, you've lost a piece of paper with the array . Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array which is consistent with information you have about equality or non-equality of corresponding pairs?
The first line contains a single integer () — the number of test cases. Next cases follow.
The first and only line of each test case contains a non-empty string consisting of characters E and/or N. The length of is equal to the size of array and . For each from to :
- if E then is equal to ( for );
- if N then is not equal to ( for ).
For each test case, print YES if it's possible to choose array that are consistent with information from you know. Otherwise, print NO.
It can be proved, that if there exists some array , then there exists an array of positive integers with values less or equal to .
Input
The first line contains a single integer () — the number of test cases. Next cases follow.
The first and only line of each test case contains a non-empty string consisting of characters E and/or N. The length of is equal to the size of array and . For each from to :
- if E then is equal to ( for );
- if N then is not equal to ( for ).
Output
For each test case, print YES if it's possible to choose array that are consistent with information from you know. Otherwise, print NO.
It can be proved, that if there exists some array , then there exists an array of positive integers with values less or equal to .
Note
In the first test case, you can choose, for example, .
In the second test case, there is no array , since, according to , is equal to , but, according to , is not equal to .
In the third test case, you can, for example, choose array .
In the fourth test case, you can, for example, choose .