#P1620A. Equal or Not Equal

    ID: 1498 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>constructive algorithmsdsuimplementation*800

Equal or Not Equal

Description

You had nn positive integers a1,a2,,ana_1, a_2, \dots, a_n arranged in a circle. For each pair of neighboring numbers (a1a_1 and a2a_2, a2a_2 and a3a_3, ..., an1a_{n - 1} and ana_n, and ana_n and a1a_1), you wrote down: are the numbers in the pair equal or not.

Unfortunately, you've lost a piece of paper with the array aa. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array aa which is consistent with information you have about equality or non-equality of corresponding pairs?

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases. Next tt cases follow.

The first and only line of each test case contains a non-empty string ss consisting of characters E and/or N. The length of ss is equal to the size of array nn and 2n502 \le n \le 50. For each ii from 11 to nn:

  • if si=s_i = E then aia_i is equal to ai+1a_{i + 1} (an=a1a_n = a_1 for i=ni = n);
  • if si=s_i = N then aia_i is not equal to ai+1a_{i + 1} (ana1a_n \neq a_1 for i=ni = n).

For each test case, print YES if it's possible to choose array aa that are consistent with information from ss you know. Otherwise, print NO.

It can be proved, that if there exists some array aa, then there exists an array aa of positive integers with values less or equal to 10910^9.

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases. Next tt cases follow.

The first and only line of each test case contains a non-empty string ss consisting of characters E and/or N. The length of ss is equal to the size of array nn and 2n502 \le n \le 50. For each ii from 11 to nn:

  • if si=s_i = E then aia_i is equal to ai+1a_{i + 1} (an=a1a_n = a_1 for i=ni = n);
  • if si=s_i = N then aia_i is not equal to ai+1a_{i + 1} (ana1a_n \neq a_1 for i=ni = n).

Output

For each test case, print YES if it's possible to choose array aa that are consistent with information from ss you know. Otherwise, print NO.

It can be proved, that if there exists some array aa, then there exists an array aa of positive integers with values less or equal to 10910^9.

Sample Input 1

4
EEE
EN
ENNEENE
NENN

Sample Output 1

YES
NO
YES
YES

Note

In the first test case, you can choose, for example, a1=a2=a3=5a_1 = a_2 = a_3 = 5.

In the second test case, there is no array aa, since, according to s1s_1, a1a_1 is equal to a2a_2, but, according to s2s_2, a2a_2 is not equal to a1a_1.

In the third test case, you can, for example, choose array a=[20,20,4,50,50,50,20]a = [20, 20, 4, 50, 50, 50, 20].

In the fourth test case, you can, for example, choose a=[1,3,3,7]a = [1, 3, 3, 7].