Олимпиадный тренинг

Задача 38137. Fence clockwise


Farmer John decided to replace the fence around his pasture.
This new fence is described by a string of characters, each of which is "N" (north), "E" (east), "S" (south), or "W" (west). Each symbol describes 1 meter of the fence. For example, if the string is NESW, this means that the fence will start one meter north, then 1 meter east, then 1 meter south, and then 1 meter west, returning to the stratum point.

The hedge always ends in the same position where it started, and it is the only point visited more than once by the hedge (and the starting point, the only point visited a second time, is at the end of the path). As a consequence, the fence encloses a single connected region of grassy pasture, even though that region may have a rather odd shape.

Farmer John wants to know if the indicated path is going clockwise or counterclockwise? Clockwise - the fenced region is on the right side of the fence, if you go along the path defined by the line. Counterclockwise - the fenced region is on the left side of the fence, if you go along the path defined by the line.

Input: 
The first line contains an integer N (1≤N≤20). Each of the following N lines contains a string of at least 4 characters and at most 100 characters, describing the path of the fence.
Output: 
For each of the N paths described by input, print a line containing "CW" (clockwise - clockwise) or "CCW" (counterclockwise).
 
Examples
# Input Output Explanation
1 2
NESW
WSSSEENWNEESSENNNNWWWS 
CW
CCW
Both paths   (? space character) denotes a starting point:

*>*
^v

<*

  *<*<*<*
  v    ^
*<
     *
v      ^
* *>*>* *
^   ^
* *<* * *
v  ^ v ^
*>*>* *>*