func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const double pi = 3.14159265358979323846;   const long long mxN = 2e5 + 2;   void _print(long long t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(double t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   vector<long long> adj[27];   long long degree[27];   bool visited[27];   vector<long long> hold;   void dfs(long long src) {     visited[src] = true;     hold.push_back(src);     for (auto edge : adj[src]) {       if (!visited[edge]) dfs(edge);     }   }   void solve() {     string s;     cin >> s;     long long n = s.length();     memset(degree, 0, sizeof(degree));     memset(visited, false, sizeof(visited));     hold.clear();     vector<vector<long long>> hehe(26, vector<long long>(26, 0));     for (long long i = 0; i <= 25; i++) adj[i].clear();     for (long long i = 0; i < n - 1; i++) {       if (s[i] != s[i + 1] && hehe[s[i] -  a ][s[i + 1] -  a ] == 0) {         adj[s[i] -  a ].push_back(s[i + 1] -  a );         adj[s[i + 1] -  a ].push_back(s[i] -  a );         hehe[s[i] -  a ][s[i + 1] -  a ] = 1;         hehe[s[i + 1] -  a ][s[i] -  a ] = 1;         degree[s[i + 1] -  a ]++;         degree[s[i] -  a ]++;       }     }     long long onecount = 0;     long long pos = -1;     if (n == 1) pos = s[0] -  a ;     for (long long i = 0; i <= 25; i++) {       if (degree[i] > 2) {         cout <<  NO n ;         return;       }       if (degree[i] == 1) {         onecount++;         pos = i;       }     }     if (n != 1 && onecount != 2) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     dfs(pos);     for (long long i = 0; i < 26; i++) {       if (!visited[i]) hold.push_back(i);     }     for (auto x : hold) cout << char(x +  a );     cout <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long T = 1;     cin >> T;     while (T--) {       solve();     }     return 0;   }   