You had $n$ positive integers $a_1, a_2, \dots, a_n$ arranged in a circle. For each pair of neighboring numbers ($a_1$ and $a_2$, $a_2$ and $a_3$, ..., $a_{n - 1}$ and $a_n$, and $a_n$ and $a_1$), you wrote down: are the numbers in the pair equal or not.

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


-----Input-----

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

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

if $s_i =$ E then $a_i$ is equal to $a_{i + 1}$ ($a_n = a_1$ for $i = n$);

if $s_i =$ N then $a_i$ is not equal to $a_{i + 1}$ ($a_n \neq a_1$ for $i = n$).


-----Output-----

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

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


-----Examples-----

Input
4
EEE
EN
ENNEENE
NENN
Output
YES
NO
YES
YES


-----Note-----

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

In the second test case, there is no array $a$, since, according to $s_1$, $a_1$ is equal to $a_2$, but, according to $s_2$, $a_2$ is not equal to $a_1$.

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

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

Source: codeforces | Difficulty: EASY
Tags: Spanning trees

Implementation

Constructive algorithms


Solutions:
for t in range(int(input())):
	print(['YES', 'NO'][input().count('N') == 1])


t = int(input())
for _ in range(t):
	pair = input()
	if len(pair) == 2:
		if pair == 'EN' or pair == 'NE':
			print('NO')
		else:
			print('YES')
	else:
		c = pair.count('N')
		if c == 1:
			print('NO')
		else:
			print('YES')


import os
import sys
from io import BytesIO, IOBase
alphabets = 'abcdefghijklmnopqrstuvwxyz'
from sys import maxsize
from itertools import permutations
import math
Modulo = 998244353

def arr_input():
	return list(map(int, input().split()))

def mul_input():
	return map(int, input().split())

def int_inp():
	return int(input())
from math import gcd
from collections import Counter
from functools import reduce

def solution():
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')

def main():
	testcases = int(input())
	for _ in range(testcases):
		solution()

def main1():
	testcases = 1
	for _ in range(testcases):
		solution()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


r = int(input())
res = []
for i in range(r):
	s = input()
	if s.count('N') == 1:
		res.append('NO')
	else:
		res.append('YES')
for i in res:
	print(i)


for _ in range(int(input())):
	str = input()
	n = str.count('N')
	if n == 1:
		print('NO')
	else:
		print('YES')


for s in [*open(0)][1:]:
	print('YNEOS'[s.count('N') == 1::2])


n = int(input())
for i in range(n):
	s = input('')
	c = 0
	for i in range(len(s)):
		if 'N' == s[i]:
			c = c + 1
	if c == len(s) or c != 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	print('NO' if s.count('N') == 1 else 'YES')


for i in range(int(input())):
	s = str(input())
	x = list(s)
	a = []
	b = []
	for i in x:
		if i == 'E':
			a.append('E')
		else:
			b.append('N')
	if len(b) == 1:
		print('NO')
	else:
		print('YES')


import math

def input_int():
	return int(input())

def input_multiple():
	return map(int, input().split())
t = input_int()
while t > 0:
	s = input()
	n = 0
	for i in s:
		if i == 'N':
			n += 1
	if s == 'EN' or s == 'NE':
		print('NO')
	elif s[0] == 'E' and s[-1] == 'E' and (n == 1):
		print('NO')
	elif (s[0] == 'N' or s[-1] == 'N') and n == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


for _ in range(int(input())):
	s = input()
	n = len(s)
	w = []
	if n == 2:
		if s == 'EN' or s == 'NE':
			print('NO')
		else:
			print('YES')
		continue
	w1 = s.count('N')
	if w1 == 1:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	if input().count('N') == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = input()
	count = 0
	if a.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	s = input()
	curr = 0
	for c in s:
		if c == 'N':
			curr += 1
	if curr == 0 or curr > 1:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	s = input()
	nb_n = len([c for c in s if c == 'N'])
	if nb_n == 1 and len(s) >= 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for q in range(t):
	s = input()
	N = len(s)
	(e, n) = (0, 0)
	for i in range(N):
		if s[i] == 'E':
			e += 1
		else:
			n += 1
	if n == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	S = [ch for ch in s]
	cnt = 0
	for ch in s:
		if ch == 'N':
			cnt += 1
	if len(s) == 2:
		if s == 'EE' or s == 'NN':
			print('YES')
		else:
			print('NO')
	elif cnt == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	a = input()
	if a.count('N') == 1:
		print('NO')
	else:
		print('YES')


T = int(input())
for x in range(T):
	s = list(input())
	ct = 0
	for c in s:
		if c == 'N':
			ct += 1
	if ct == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	s = input()
	c = 0
	for d in s:
		if d == 'N':
			c += 1
	if c == 1:
		print('NO')
	else:
		print('YES')


import sys
cases = int(sys.stdin.readline())
for _ in range(cases):
	res = sum(map(lambda c: 1 if c == 'N' else 0, list(sys.stdin.readline().strip())))
	print('NO' if res == 1 else 'YES')


t = int(input())
for ttt in range(t):
	a = input()
	if a.count('N') == 1:
		if a[:a.index('N')] == 'E' * a.index('N') and a[a.index('N') + 1:] == 'E' * (len(a) - a.index('N') - 1):
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	st = input()
	cnt = 0
	for s in st:
		if s == 'N':
			cnt += 1
	if cnt != 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


import math, sys
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop

def solve():
	s = list(input())
	n = len(s)
	a = [-1 for i in range(n)]
	a[0] = cnt = 1
	(i, j) = (1, n - 1)
	while i < n and s[i - 1] == 'E':
		a[i] = a[0]
		i += 1
	while j >= 0 and s[j] == 'E':
		a[j] = a[0]
		j -= 1
	for k in range(i - 1, j + 1):
		if s[k] == 'E':
			nxt = (k + 1) % n
			if a[nxt] == -1:
				a[nxt] = a[k]
			elif a[k] != a[nxt]:
				print('NO')
				return
		else:
			cnt += 1
			nxt = (k + 1) % n
			if a[nxt] == -1:
				a[nxt] = cnt
			elif a[k] == a[nxt]:
				print('NO')
				return
	print('YES')

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def flush():
	sys.stdout.flush()
main()


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	s = get_string()
	n = len(s)
	count = 0
	for ele in s:
		if ele == 'N':
			count += 1
	if count == 0 or count == n:
		print('YES')
		return
	if count == 1:
		print('NO')
		return
	print('YES')
T = get_int()
while T:
	solve()
	T -= 1


t = int(input())
for i in range(t):
	s = input()
	if 'N' in s:
		index = s.rfind('N')
		if s[:index].count('N') == 0:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


test_case = int(input(''))
for i in range(test_case):
	string = input('')
	e = 0
	n = 0
	for x in string:
		if x == 'E':
			e = e + 1
		elif x == 'N':
			n = n + 1
	if n >= 2 or n == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input().strip())):
	s = input().strip()
	cnt = 0
	for i in range(len(s)):
		if s[i] == 'N':
			cnt += 1
		if cnt > 1:
			break
	if cnt == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	c = 0
	for i in range(len(s)):
		if s[i] == 'N':
			c += 1
		if c >= 2:
			print('YES')
			break
	if c == 0:
		print('YES')
	elif c == 1:
		print('NO')


t = int(input())
l = ['YES'] * t
for i in range(t):
	s = input()
	if s.count('N') == 1:
		l[i] = 'NO'
for i in l:
	print(i)


import math

def intlist():
	return [int(i) for i in input().split(' ')]

def stringlsit():
	return input().split(' ')

def solve():
	s = input()
	if s.count('N') == 1:
		return 'NO'
	return 'YES'
t = input()
for tt in range(int(t)):
	print(solve())


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')


def solve(s):
	n = len(s) - 1
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')
t = int(input())
for test_case in range(t):
	s = input()
	solve(s)


for _ in range(int(input())):
	s = input()
	if len(s) == 2:
		if s[0] == s[-1]:
			print('YES')
		else:
			print('NO')
	elif s.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	res = 0
	for j in range(len(s)):
		if s[j] == 'N':
			res += 1
	if res == 1 and len(s) != 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	s = input()
	n_count = 0
	for i in range(len(s)):
		if s[i] == 'N':
			n_count += 1
	if n_count == 1:
		print('NO')
	else:
		print('YES')


def countN(word):
	return word.count('N')
n = int(input())
for i in range(n):
	word = input()
	if countN(word) == 1:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	for _ in range(t):
		s = input()
		cnt = 0
		for c in s:
			if c == 'N':
				cnt += 1
		if cnt == 1:
			print('NO')
		else:
			print('YES')
main()


t = int(input())
for _ in range(t):
	s = input()
	n = 0
	for c in s:
		if c == 'N':
			n = n + 1
	if n == 1 and len(s) > 1:
		print('No')
	else:
		print('yes')


def equal():
	s = input()
	count = s.count('N')
	if count != 1:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	equal()


import sys
import math
from bisect import bisect_right as br
from collections import deque
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	st = input()
	if st.count('N') == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):

	def checker(user: str) -> str:
		return 'NO' if user.count('N') == 1 else 'YES'
	print(checker(input()))


import sys
for _ in range(int(input())):
	s = input()
	count_n = 0
	for ch in s:
		if ch == 'N':
			count_n += 1
	if count_n == 1:
		sys.stdout.write('NO\n')
	else:
		sys.stdout.write('YES\n')


cases = input()
for a in range(int(cases)):
	s = str(input())
	n = [c for c in s if c == 'N']
	ll = len(n)
	if ll == 1:
		print('NO')
	else:
		print('YES')


term = int(input())
for _ in range(term):
	str = input()
	counter = 0
	for j in range(len(str)):
		if str[j] == 'N':
			counter += 1
	if counter == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t != 0:
	s = input()
	if len(s) == 2 and s[0] != s[1]:
		print('NO')
	elif s.count('E') == len(s) - 1 and s.count('N') == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for k in range(t):
	s = input()
	a = list(s)
	count = 0
	for i in range(len(a)):
		if a[i] == 'N':
			count = count + 1
	if count == 0 or count >= 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	print(['YES', 'NO'][input().count('N') == 1])


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192

def bootstrap(f, stack=[]):

	def fun(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return fun

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	d = defaultdict(lambda : 0)
	poss = 1
	tot = 0
	for i in range(n):
		if s[i] == 'N':
			tot += 1
	if tot == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	s = str(input())
	e = s.count('E')
	n = s.count('N')
	if e == len(s) - 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	sol = s.count('N')
	if sol == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	a = input()
	b = a.count('N')
	if b == 1:
		print('NO')
	else:
		print('YES')


import sys

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		c = s.count('N')
		if c >= 2 or c == 0:
			print('YES')
		else:
			print('NO')
main()


T = int(input())
while T > 0:
	arr = input()
	if arr[-1] == 'E':
		count = arr.count('N')
		if count == 1:
			print('NO')
		else:
			print('YES')
	else:
		count = arr.count('N')
		if count == 1:
			print('NO')
		else:
			print('YES')
	T -= 1


import sys
sys.setrecursionlimit(5000001)
from collections import *
from math import *
TT = int(input())
for i in range(TT):
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	l1 = list(input())
	print('NO' if l1.count('N') == 1 else 'YES')


t = int(input())
for caseNr in range(1, t + 1):
	string = str(input())
	count = 0
	for s in string:
		if s == 'N':
			count += 1
	if count == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
while n > 0:
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')
	n -= 1


n = int(input())
while n > 0:
	s = input()
	count = 0
	for i in s:
		if i == 'N':
			count += 1
	if count == 1:
		print('NO')
	else:
		print('YES')
	n -= 1


def solve():
	s = input()
	n = 0
	e = 0
	for i in s:
		if i == 'N':
			n += 1
		elif i == 'E':
			e += 1
	if n == 1:
		print('NO')
	else:
		print('YES')
for case in range(int(input())):
	solve()


def solve():
	s = input()
	if s == 'NE' or s == 'EN':
		print('NO')
		return
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')
t = int(input())
while t:
	t -= 1
	solve()


from sys import stdin
for _ in range(int(stdin.readline())):
	s = input()
	n = 0
	for i in s:
		if i == 'N':
			n += 1
	if n == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
L = []
for i in range(t):
	s = input()
	L.append(s)
for j in range(t):
	if L[j].count('N') == 1:
		print('NO')
	else:
		print('YES')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)

def solve():
	string = input()
	return string.count('N') != 1

def main():
	t = int(input())
	while t:
		print('YES' if solve() else 'NO')
		t -= 1
main()


t = int(input())
for _ in range(t):
	s = input()
	ini = 1
	n = len(s)
	a = [0 for i in range(n)]
	a[1] = 1
	kk = 0
	for i in s:
		if i == 'N':
			kk += 1
	if kk == 1:
		print('NO')
	else:
		print('YES')


from itertools import permutations as per
from math import factorial as fact
from difflib import SequenceMatcher
t = int(input())
for _ in range(t):
	s = input()
	print('YES') if s.count('N') != 1 else print('NO')


x = int(input(''))
V = []
h = 0
for i in range(x):
	c = input('')
	l = len(c)
	h = 0
	for i in c:
		if i == 'N':
			h += 1
	if h == 1:
		V.append('NO')
	else:
		V.append('YES')
for i in V:
	print(i)


import atexit, io, sys, math, heapq, collections

def get_int():
	return int(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def write_int(a):
	sys.stdout.write(str(a) + '\n')

def write_str(a):
	sys.stdout.write(a + '\n')

def write_list(arr):
	sys.stdout.write(' '.join(map(str, arr)) + '\n')

def swap(arr, a, b):
	arr[a] ^= arr[b]
	arr[b] ^= arr[a]
	arr[a] ^= arr[b]

def int_len(a):
	return math.floor(math.log(a, 10)) + 1

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def Sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	res = []
	for i in range(2, len(prime)):
		if prime[i]:
			res.append(i)
	return res

def binarySearch(arr, l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return -1

def search(arr, x):
	return binarySearch(arr, 0, len(arr) - 1, x)

def toString(A):
	return ''.join(A)

def toArray(str):
	return str.split()

def arrSum(Arr):
	Sum = 0
	for i in range(len(Arr)):
		Sum += Arr[i]
	return Sum

def computeXOR(n):
	if n % 4 == 0:
		return n
	if n % 4 == 1:
		return 1
	if n % 4 == 2:
		return n + 1
	return 0

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isSubSequence(string1, string2, m, n):
	if m == 0:
		return True
	if n == 0:
		return False
	if string1[m - 1] == string2[n - 1]:
		return isSubSequence(string1, string2, m - 1, n - 1)
	return isSubSequence(string1, string2, m, n - 1)
N = get_int()
while N > 0:
	Str = get_string()
	A = Str.count('N')
	B = Str.count('E')
	if A == 1:
		print('NO')
	else:
		print('YES')
	N -= 1


from math import gcd
mod = 10 ** 9 + 7

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def rls():
	return list(map(str, input().split()))

def rm():
	return map(int, input().split())
for _ in range(ri()):
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for z in range(0, t):
	s = input()
	a = s.count('N')
	if a == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	print('NO' if len(list(filter(lambda x: x == 'N', input()))) == 1 else 'YES')


t = int(input())
for i in range(t):
	n = input()
	count = 0
	for i in n:
		if i == 'N':
			count += 1
	if count != 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	c = s.count('N')
	if c == 1:
		print('NO')
	else:
		print('YES')


ans = []
for _ in range(int(input())):
	s = input()
	ans.append(['YES', 'NO'][s.count('N') == 1])
print(*ans, sep='\n')


z = int(input())
for i in range(z):
	x = input()
	index = -1
	count = 0
	for k in range(len(x)):
		if x[k] == 'N':
			index = k
		else:
			count += 1
	if count == len(x) - 1:
		print('NO')
	else:
		print('YES')


n = int(input())
for q in range(n):
	a = input()
	if a.count('N') == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
k = [list(str(input())) for i in range(n)]
for i in range(n):
	str_ = k[i]
	if str_.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	en = input()
	if en.count('N') == 1:
		print('NO')
	elif en[0] == 'N' and en[len(en) - 1] == 'E':
		print('YES')
	else:
		print('YES')


times = int(input())
ans = []
for time in range(times):
	x = input()
	leng = len(x)
	med = 0
	if leng == 2:
		if x[0] != x[1]:
			ans.append('NO')
			continue
		ans.append('YES')
		continue
	for i in x:
		if i == 'N':
			med += 1
	if med == 1:
		ans.append('NO')
		continue
	ans.append('YES')
for i in ans:
	print(i)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	s = get_string()
	c = 0
	for i in range(len(s)):
		if s[i] == 'N':
			c += 1
	if c == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for o in range(t):
	s = input()
	w = s.count('N')
	if w == 1:
		print('NO')
	else:
		print('YES')


T = int(input())
for t in range(T):
	s = input()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	s = input()
	if 'E' not in s or 'N' not in s or s.count('N') > 1:
		print('YES')
	elif s.count('N') > 1 and s[-1] == 'E':
		print('YES')
	else:
		print('NO')


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(S):
	numN = len([c for c in S if c == 'N'])
	return numN != 1
TC = int(input())
for tc in range(TC):
	S = input()
	res = solve(S)
	print('YES' if res else 'NO')


a = int(input())
for _ in range(a):
	x = input()
	j = ['NO' if x.count('N') == 1 else 'YES']
	print(*j)


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	n = len(s)
	cnt = 0
	for i in range(n - 1):
		if s[i] == 'N':
			cnt += 1
	if cnt >= 2:
		return 'YES'
	elif cnt == 0 and s[-1] == 'E':
		return 'YES'
	elif cnt == 1 and s[-1] == 'N':
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	s = input()
	e = s.count('E')
	n = s.count('N')
	if n == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	count = 0
	for elem in s:
		if elem == 'N':
			count += 1
	if count == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	countn = 0
	for char in input():
		if char == 'N':
			countn += 1
	if countn == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	s = input()
	ar = list(s)
	n = len(s)
	if 'E' * n == s:
		print('YES')
		continue
	k = ar.index('N')
	if k == n - 1:
		print('NO')
	else:
		s = 0
		for j in range(k + 1, n):
			if ar[j] == 'N':
				s = s + 1
		if s >= 1:
			print('YES')
		else:
			print('NO')


import collections
for i in range(int(input())):
	s = input()
	d = collections.Counter(s)
	if 'N' in d and d['N'] == 1:
		print('NO')
		continue
	print('YES')


t = int(input())
ret = []
for ii in range(t):
	s = list(input())
	if s.count('N') == 1:
		ret.append('NO')
	else:
		ret.append('YES')
print(*ret, sep='\n')


t = int(input())
for i in range(t):
	s = input()
	k = 0
	for r in s:
		if r == 'N':
			k += 1
	if k == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = stdin.readline
try:
	for i in range(int(input())):
		s = input()
		count = 0
		for j in s:
			if j == 'N':
				count += 1
		if count == 1:
			print('no')
		if count != 1:
			print('yes')
except:
	pass


for t in range(int(input())):
	S = input()
	if S.count('N') == 1:
		print('NO')
	else:
		print('YES')


import sys
import bisect
import math
from collections import deque
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def solve():
	s = input()
	if s.count('N') == 1:
		return 'NO'
	else:
		return 'YES'
t = 1
t = int(input())
for _ in range(t):
	print(solve())


for _ in range(int(input())):
	x = input()
	ce = x.count('E')
	cn = x.count('N')
	if cn > 1 or cn == 0:
		print('YES')
	else:
		print('NO')


import sys
n = int(sys.stdin.readline().rstrip('\n'))
for _ in range(n):
	q = sys.stdin.readline().rstrip('\n')
	predicted = [0]
	count = 0
	for (i, e) in enumerate(q):
		if e == 'N':
			count += 1
	if count == 1:
		print('NO')
	else:
		print('YES')


from math import sqrt
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	s = input().strip()
	if s.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = input()
for _ in range(int(t)):
	s = input()
	if len(set(list(s))) == 1:
		print('YES')
	elif s.count('N') == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	a = input()
	n = 0
	for j in range(len(a)):
		if a[j] == 'N':
			n += 1
	if n == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	mass = input()
	mass = list(mass)
	h = len(mass)
	if h > 2:
		if mass.count('N') == 1:
			print('NO')
		else:
			print('YES')
	elif mass[0] == mass[1]:
		print('YES')
	else:
		print('NO')


t = int(input())
cnt = 0
for i in range(1, t + 1):
	s = input()
	for i in s:
		if i == 'N':
			cnt += 1
	if cnt == 1:
		print('NO')
	else:
		print('YES')
	cnt = 0


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	s = input().strip()
	count = 0
	for c in s:
		if c == 'N':
			count += 1
	if count == 1:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	s = str(input())
	x = 0
	for i in range(len(s)):
		if s[i] == 'N':
			x += 1
	if x == 1:
		print('NO')
	else:
		print('YES')


q = []
for _ in range(int(input())):
	q.append(input())
for _ in range(len(q)):
	s = q[_]
	temp = s[0]
	if s.count('E') == len(s) - 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	s = input()
	(e, n) = (0, 0)
	ans = 0
	for i in range(len(s)):
		if s[i] == 'N':
			n = 1
			ans += 1
		else:
			e = 1
	if ans < 2 and n and e:
		print('NO')
	else:
		print('YES')


from collections import Counter
t = int(input())
for _ in range(t):
	s = input()
	d = Counter(s)
	if len(s) > 0 and d['N'] == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = list(str(input()))
	n = len(a)
	cnt = 0
	for i in range(n):
		if a[i] == 'N':
			cnt += 1
	if cnt != 1:
		print('YES')
	else:
		print('NO')


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		S = input()
		if S.count('N') == 1:
			print('NO')
		else:
			print('YES')
main()


t = int(input())
arr = []
for i in range(t):
	arr.append(input())
for s in arr:
	check = s.count('N')
	if check == 1:
		print('NO')
	else:
		print('YES')


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right, insort
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	s = list(input().strip())
	if 'E' in s and s.count('N') == 1:
		print('NO')
	else:
		print('YES')


import sys
IN = sys.stdin
OUT = sys.stdout
tc = int(IN.readline())
for ti in range(tc):
	s = IN.readline().strip()
	a = 0
	for c in s:
		if c == 'N':
			a += 1
	if a == 1:
		print('NO')
	else:
		print('YES')


def check(x, mat, n, m):
	flag = False
	pair = [False] * m
	for i in range(n):
		c = 0
		for j in range(m):
			if mat[i][j] >= x:
				pair[j] = True
				c += 1
		if c > 1:
			flag = True
	if not flag and m > 1:
		return False
	ans = sum(pair)
	if ans == m:
		return True
	return False
import sys

def solve():
	for t in range(int(input())):
		s = input()
		N = 0
		for ele in s:
			if ele == 'N':
				N += 1
		if N == 1:
			print('NO')
		else:
			print('YES')
solve()


from math import *
for t in range(int(input())):
	print('NO' if input().count('N') == 1 else 'YES')


from sys import stdin

def readint():
	return int(stdin.readline().strip())

def readints(delim=' '):
	return map(int, stdin.readline().strip().split(delim))

def readstr():
	return stdin.readline().strip()

def answer(query):
	if query.count('N') == 1:
		return 'NO'
	else:
		return 'YES'

def main():
	t = readint()
	for _ in range(t):
		query = readstr()
		print(answer(query))
main()


def solve():
	a = list(input())
	dem_E = 0
	dem_N = 0
	for i in a:
		if i == 'E':
			dem_E += 1
		else:
			dem_N += 1
	if dem_N == 1 and dem_E == len(a) - 1:
		print('NO')
	else:
		print('YES')
for i in range(int(input())):
	solve()


def solve():
	s = input()
	print('No' if s.count('N') == 1 else 'Yes')
t = int(input())
for tc in range(t):
	solve()


n = int(input())
results = []
for i in range(n):
	s = input()
	if s.count('N') > 1 or s.count('N') == 0:
		results.append('YES')
	else:
		results.append('NO')
for i in results:
	print(i)