#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
vector<long long> vec;
long long t, n, m, k;
string anse;
bool matr[26][26];
bool flag = false, used[26];
void dfs(int v, int par = -1) {
  used[v] = true;
  for (int i = 0; i < 26; i++) {
    if (matr[v][i] && !used[i] && i != par) {
      dfs(i, v);
    } else if (matr[v][i] && used[i] && i != par) {
      flag = true;
    }
  }
}
void dfs2(int v, int par = -1) {
  used[v] = true;
  anse.push_back(v);
  for (int i = 0; i < 26; i++) {
    if (matr[v][i] && !used[i]) {
      dfs2(i, v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  string ans;
  while (t--) {
    ans.resize(0);
    for (int i = 0; i < 26; i++) {
      used[i] = false;
      for (int j = 0; j < 26; j++) {
        matr[i][j] = false;
      }
    }
    string s;
    cin >> s;
    vector<set<long long>> close;
    close.resize(26);
    for (int i = 0; i < s.size(); i++) {
      if (i > 0) {
        close[s[i] - 'a'].insert(s[i - 1] - 'a');
        matr[s[i] - 'a'][s[i - 1] - 'a'] = true;
      }
      if (i < s.size() - 1) {
        close[s[i] - 'a'].insert(s[i + 1] - 'a');
        matr[s[i] - 'a'][s[i + 1] - 'a'] = true;
      }
    }
    flag = false;
    for (int i = 0; i < 26; i++) {
      if (close[i].size() > 2) flag = true;
    }
    for (int i = 0; i < 26; i++) {
      if (!used[i]) dfs(i);
    }
    if (flag) {
      cout << "NO\n";
    } else {
      for (int i = 0; i < 26; i++) {
        used[i] = false;
      }
      anse.resize(0);
      for (int i = 0; i < 26; i++) {
        if (!used[i] && close[i].size() <= 1) dfs2(i);
      }
      cout << "YES\n";
      for (int i = 0; i < anse.size(); i++) {
        char c = anse[i] + 'a';
        cout << c;
      }
      cout << "\n";
    }
  }
  return 0;
}
