#P9945. Determine Fence Orientation

    ID: 23089 Type: Default 1000ms 256MiB

Determine Fence Orientation

Determine Fence Orientation

Farmer John's fence around his largest field was recently replaced, but not without incident. While laying down the new fence, a giant bee chased him, and he ended up laying the fence along a rather irregular path. The fence is represented as a string, where each character corresponds to a one meter move in one of the four cardinal directions: 'N' for north, 'E' for east, 'S' for south, and 'W' for west. The path always starts and ends at the same point, and the starting point is the only point where the fence is visited twice.

This fence encloses a connected region of grass. Farmer John wonders whether the fence was built in a clockwise fashion (when following the order of the moves, the enclosed area lies to the right) or in a counterclockwise fashion (the area lies to the left).

One common technique to determine the orientation of a polygon is the shoelace formula:

\( A = \frac{1}{2}\sum_{i=0}^{n-1}(x_i y_{i+1} - x_{i+1} y_i) \)

If \(A

inputFormat

The input consists of a single line containing a string made up of the characters N, E, S, and W. This string represents the one-meter moves that Farmer John makes while laying the fence. The path is guaranteed to be closed, meaning the endpoint coincides with the starting point.

outputFormat

Output a single line with either CW if the path is oriented clockwise, or CCW if the path is oriented counterclockwise.

sample

NESW
CW