description: You had n positive integers a_1, a_2, ..., 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 ≤ t ≤ 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 ≤ n ≤ 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 ≠ 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.
  
  Example
  
  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].
solution: import java.util.*;
  import java.io.*;
  import java.math.BigInteger;
  
  public class Main {
  	static int[][] grid;
  
  	static int res[][];
  
  	public static void main(String[] args) throws IOException, InterruptedException {
  		Scanner sc = new Scanner(System.in);
  		PrintWriter pw = new PrintWriter(System.out);
  		int t = sc.nextInt();
  		while (t-- > 0) {
  			String s = sc.nextLine();
  			int cE = 0;
  			int cN = 0;
  			for (int i = 0; i < s.length(); i++) {
  				if(s.charAt(i)=='E')
  					cE++;
  				else
  					cN++;
  			}
  			if(cN==1) {
  				pw.println("NO");
  			}
  			else {
  				pw.println("YES");
  			}
  		}
  		pw.flush();
  	}
  
  	static int bs(Integer[] arr, int x) {
  		int start = 0;
  		int end = arr.length - 1;
  		while (start <= end) {
  			int mid = (start + end) / 2;
  			if (arr[mid] > x) {
  				end = mid - 1;
  			} else {
  				start = mid + 1;
  			}
  		}
  		return start;
  	}
  }
  
  class segTree {
  	long[] arr, sTree;
  	int n;
  
  	public segTree(long[] a) {
  		n = 1;
  		while (n < a.length)
  			n <<= 1;
  
  		arr = new long[n + 1];
  		Arrays.fill(arr, Long.MAX_VALUE);
  		for (int i = 0; i < a.length; i++) {
  			arr[i + 1] = a[i];
  		}
  		sTree = new long[n << 1];
  		build(1, 1, n);
  	}
  
  	public void build(int curr, int l, int r) {
  //		if(l>r)
  //			return;
  		if (l == r) {
  			sTree[curr] = arr[curr - (n - 1)];
  			return;
  		}
  		int mid = (l + r) >> 1;
  		build(curr << 1, l, mid);
  		build((curr << 1) + 1, mid + 1, r);
  		sTree[curr] = Math.min(sTree[curr << 1], sTree[(curr << 1) + 1]);
  	}
  
  	public long q(int l, int r) {
  		return query(1, l, r, 1, n);
  	}
  
  	public long query(int curr, int qL, int qR, int l, int r) {
  		if (l >= qL && r <= qR) {
  			return sTree[curr];
  		}
  		if (r < qL || l > qR) {
  			return Long.MAX_VALUE;
  		}
  		int mid = (l + r) >> 1;
  		long left = query((curr << 1), qL, qR, l, mid);
  		long right = query((curr << 1) + 1, qL, qR, mid + 1, r);
  		return Math.min(left, right);
  	}
  
  	public void update(int i, int val) {
  		i = i + n - 1;
  		sTree[i] = val;
  		i >>= 1;
  		while (i >= 1) {
  			sTree[i] = sTree[i << 1] + sTree[(i << 1) + 1];
  			i >>= 1;
  		}
  	}
  }
  
  class Scanner {
  	StringTokenizer st;
  	BufferedReader br;
  
  	public Scanner(InputStream s) {
  		br = new BufferedReader(new InputStreamReader(s));
  	}
  
  	public String next() throws IOException {
  		while (st == null || !st.hasMoreTokens())
  			st = new StringTokenizer(br.readLine());
  		return st.nextToken();
  	}
  
  	public int nextInt() throws IOException {
  		return Integer.parseInt(next());
  	}
  
  	public long nextLong() throws IOException {
  		return Long.parseLong(next());
  	}
  
  	public String nextLine() throws IOException {
  		return br.readLine();
  	}
  
  	public double nextDouble() throws IOException {
  		String x = next();
  		StringBuilder sb = new StringBuilder("0");
  		double res = 0, f = 1;
  		boolean dec = false, neg = false;
  		int start = 0;
  		if (x.charAt(0) == '-') {
  			neg = true;
  			start++;
  		}
  		for (int i = start; i < x.length(); i++)
  			if (x.charAt(i) == '.') {
  				res = Long.parseLong(sb.toString());
  				sb = new StringBuilder("0");
  				dec = true;
  			} else {
  				sb.append(x.charAt(i));
  				if (dec)
  					f *= 10;
  			}
  		res += Long.parseLong(sb.toString()) / f;
  		return res * (neg ? -1 : 1);
  	}
  
  	public boolean ready() throws IOException {
  		return br.ready();
  	}
  
  	public int[] nextIntArr(int n) throws IOException {
  		int[] arr = new int[n];
  		for (int i = 0; i < arr.length; i++) {
  			arr[i] = nextInt();
  		}
  		return arr;
  	}
  
  	public long[] nextLongArr(int n) throws IOException {
  		long[] arr = new long[n];
  		for (int i = 0; i < arr.length; i++) {
  			arr[i] = nextLong();
  		}
  		return arr;
  	}
  }