func_code_string: #include <bits/stdc++.h>   using namespace std;   int dx[] = {-1, 1, 0, 0};   int dy[] = {0, 0, -1, 1};   long long int sizes[100001];   long long int arr[100001];   bool ok = true;   long long int A[100001];   pair<long long int, long long int> B[100001];   long long int root(long long int i) {     while (i != arr[i]) i = arr[i];     return (i);   }   void Union(long long int i, long long int j) {     long long int root_i = root(i), root_j = root(j);     if (root_i == root_j) return;     if (sizes[root_i] > sizes[root_j]) swap(root_i, root_j);     sizes[root_j] += sizes[root_i];     arr[root_i] = arr[root_j];     return;   }   long long int Arr[100001];   bool solve(long long int n) {     if (n == 1) return (true);     set<long long int> st;     for (long long int i = 0; i < n; i++) {       long long int m = (Arr[i] + i) % n;       if (m < 0) m += n;       if (st.count(m)) return (false);       st.insert(m);     }     return (true);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       string s;       cin >> s;       set<pair<pair<long long int, long long int>,                pair<long long int, long long int> > >           st;       long long int ans = 0, x = 0, y = 0;       for (long long int i = 0; i < s.size(); i++) {         long long int a, b, c, d;         if (s[i] ==  N ) {           a = x;           b = y + 1;           c = 0;           d = 1;         } else if (s[i] ==  S ) {           a = x;           b = y - 1;           c = 0;           d = -1;         } else if (s[i] ==  W ) {           a = x + 1;           b = y;           c = 1;           d = 0;         } else if (s[i] ==  E ) {           a = x - 1;           b = y;           c = -1;           d = 0;         }         if (st.count(pair<pair<long long int, long long int>,                           pair<long long int, long long int> >(                 pair<long long int, long long int>(x, y),                 pair<long long int, long long int>(a, b))))           ans++;         else if (st.count(pair<pair<long long int, long long int>,                                pair<long long int, long long int> >(                      pair<long long int, long long int>(a, b),                      pair<long long int, long long int>(x, y))))           ans++;         else           ans += 5;         st.insert(pair<pair<long long int, long long int>,                        pair<long long int, long long int> >(             pair<long long int, long long int>(x, y),             pair<long long int, long long int>(a, b)));         x += c;         y += d;       }       cout << ans <<   n ;     }     return (0);   }   