#K96102. Cyclic Path Validator
Cyclic Path Validator
Cyclic Path Validator
This problem requires you to determine whether a given path in a 2D grid is cyclic. A path is considered cyclic if, after following a series of moves represented by the characters \(N\), \(S\), \(E\), and \(W\) (which denote north, south, east, and west respectively), you return to the starting point \((0, 0)\).
You are given \(T\) test cases. For each test case, compute whether the provided path is cyclic. If the path is cyclic, output 1; otherwise, output 0. An empty path is considered cyclic.
inputFormat
The first line of input contains an integer (T) representing the number of test cases. Each of the following (T) lines contains a string representing the path. The string consists solely of the uppercase letters 'N', 'S', 'E', and 'W'.
outputFormat
For each test case, output a single line with an integer: 1 if the path is cyclic (i.e., returns to ((0, 0))), and 0 otherwise.## sample
4
NESW
NNSS
EW
NNEESWWS
1
1
1
1
</p>