#include <bits/stdc++.h>
using namespace std;
long long vis[26], root;
set<long long> adj[26];
string req;
void dfs(long long idx) {
  vis[idx] = 1;
  req.push_back(idx + 'a');
  for (auto node : adj[idx])
    if (!vis[node]) dfs(node);
}
signed main() {
  std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  long long CASE = 1;
  cin >> CASE;
  while (CASE--) {
    for (long long i = 0; i < 26; ++i) adj[i].clear();
    req.clear();
    string s;
    cin >> s;
    if ((long long)s.size() == 1) {
      cout << "YES" << '\n';
      for (long long i = 0; i < 26; ++i) cout << char(i + 'a');
      cout << '\n';
      continue;
    }
    for (long long i = 1; i < (long long)s.size(); ++i) {
      adj[s[i] - 'a'].insert(s[i - 1] - 'a');
      adj[s[i - 1] - 'a'].insert(s[i] - 'a');
    }
    long long cnt1 = 0, f = 1;
    for (long long i = 0; i < 26; ++i) {
      if ((long long)adj[i].size() == 1)
        cnt1++;
      else if ((long long)adj[i].size() > 2)
        f = 0;
    }
    if (!f || cnt1 != 2) {
      cout << "NO" << '\n';
      continue;
    }
    memset(vis, 0, sizeof vis);
    for (long long i = 0; i < 26; ++i) {
      if ((long long)adj[i].size() == 1) {
        root = i;
        break;
      }
    }
    dfs(root);
    for (long long i = 0; i < 26; ++i)
      if (!vis[i]) req.push_back(i + 'a');
    cout << "YES" << '\n';
    cout << req << '\n';
  }
  return 0;
}
