#include <bits/stdc++.h>
using namespace std;
void dfs(vector<set<int>> &v, int pocetak, vector<int> &visited, string &s) {
  visited[pocetak] = 1;
  if (s[s.size() - 1] == 'G') {
    return;
  }
  int brojac = 0;
  for (set<int>::iterator it = v[pocetak].begin(); it != v[pocetak].end();
       ++it) {
    if (visited[*it] == 1) {
      brojac++;
      if (brojac == 2) {
        s += 'G';
        return;
      }
    }
    if (visited[*it] == 0) {
      dfs(v, *it, visited, s);
      s += *it + 'a';
      visited[*it] = 2;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<set<int>> v(26);
    vector<int> visited(26, 0);
    for (int i = 0; i < s.size(); i++) {
      if (i - 1 >= 0) {
        v[s[i] - 'a'].insert(s[i - 1] - 'a');
      }
      if (i + 1 < s.size()) {
        v[s[i] - 'a'].insert(s[i + 1] - 'a');
      }
    }
    string resenje = "";
    bool jelTacno = true;
    bool jelUsao = false;
    for (int i = 0; i < s.size(); i++) {
      if (v[s[i] - 'a'].size() > 2) {
        jelTacno = false;
        break;
      }
      if (visited[s[i] - 'a'] == 0 &&
          (v[s[i] - 'a'].size() == 1 || v[s[i] - 'a'].size() == 0)) {
        jelUsao = true;
        dfs(v, s[i] - 'a', visited, resenje);
        if (resenje[resenje.size() - 1] == 'G') {
          jelTacno = false;
          break;
        } else {
          resenje += s[i];
        }
      }
    }
    if (jelTacno == false || jelUsao == false) {
      cout << "NO\n";
      continue;
    }
    for (int i = 0; i < 26; i++) {
      if (visited[i] == 0) {
        resenje += i + 'a';
      }
    }
    cout << "YES\n";
    cout << resenje << '\n';
  }
  return 0;
}
