#include <bits/stdc++.h>
using namespace std;
bool check_duplicate(vector<int> a, int x) {
  for (auto p : a) {
    if (p == x) return true;
  }
  return false;
}
void solve() {
  string s;
  cin >> s;
  vector<vector<int>> adj(27);
  int n = s.size();
  if (n == 1) {
    cout << "YES" << endl;
    for (int i = 0; i < 26; i++) {
      cout << (char)(i + 'a');
    }
    cout << "\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      if (s[i] == s[i - 1]) {
        cout << "NO"
             << "\n";
        return;
      }
      if (!check_duplicate(adj[s[i] - 'a'], s[i - 1] - 'a'))
        adj[s[i] - 'a'].push_back(s[i - 1] - 'a');
    }
    if (i < n - 1) {
      if (!check_duplicate(adj[s[i] - 'a'], s[i + 1] - 'a'))
        adj[s[i] - 'a'].push_back(s[i + 1] - 'a');
    }
  }
  for (int i = 0; i < 27; i++) {
    if (adj[i].size() > 2) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  int next = -1;
  for (int i = 0; i < 27; i++) {
    if (adj[i].size() == 1) {
      next = i;
      break;
    }
  }
  if (next == -1) {
    cout << "NO"
         << "\n";
    return;
  }
  vector<int> ans;
  vector<int> used(27, 0);
  ans.push_back(next);
  used[next]++;
  int done = 0;
  while (!done) {
    if (adj[next].size() > 0 && !used[adj[next][0]]) {
      ans.push_back(adj[next][0]);
      used[adj[next][0]]++;
      next = adj[next][0];
    } else if (adj[next].size() > 1 && !used[adj[next][1]]) {
      ans.push_back(adj[next][1]);
      used[adj[next][1]]++;
      next = adj[next][1];
    } else
      done = 1;
  }
  for (int i = 0; i < 26; i++) {
    if (!used[i]) ans.push_back(i);
  }
  cout << "YES"
       << "\n";
  for (int x : ans) {
    cout << (char)(x + 'a');
  }
  cout << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
