text: #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  #define INF 1000000007
  
  int main() {
      ios::sync_with_stdio(0);
      cin.tie(0), cout.sync_with_stdio(0);
      int N; cin >> N;
      for(int i=0; i<N; ++i) {
          string str;
          cin >> str;
          int x=0, y=0;
          int miny=INF, maxy=-INF, minx=INF, maxx=-INF;
          char left, right, up, down;
          for(char c : str) {
              if(c=='N') {
                  y++;
                  if(x>=maxx) {
                      maxx=x;
                      right=c;
                  }if(x<=minx) {
                      minx=x;
                      left=c;
                  }
              }else if(c=='W') {
                  x--;
                  if(y>=maxy) {
                      maxy=y;
                      up=c;
                  }if(y<=miny) {
                      miny=y;
                      down=c;
                  }
              }else if(c=='S') {
                  y--;
                  if(x>=maxx) {
                      maxx=x;
                      right=c;
                  }if(x<=minx) {
                      minx=x;
                      left=c;
                  }
              }else {
                  x++;
                  if(y>=maxy) {
                      maxy=y;
                      up=c;
                  }if(y<=miny) {
                      miny=y;
                      down=c;
                  }
              }
  
          }
          /*
          cout << "right: " << right << endl;
          cout << "left: " << left << endl;
          cout << "up: " << up << endl;
          cout << "down: " << down << endl;
          */
          if(right=='N' && left=='S') {
              cout << "CCW" << endl;
          }else {
              cout << "CW" << endl;
          }
      }
  }
  