#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  if (n == 1) {
    cout << "YES\n" << s;
    for (char i = 'a'; i <= 'z'; i++) {
      if (i != s[0]) cout << i;
    }
    cout << "\n";
    return;
  }
  map<char, set<char> > g;
  bool vs[26] = {0}, v1[26] = {0};
  for (int i = 0; i < n; i++) {
    if (i > 0) g[s[i]].insert(s[i - 1]);
    if (i < n - 1) g[s[i]].insert(s[i + 1]);
    vs[s[i] - 'a'] = 1;
    v1[s[i] - 'a'] = 1;
  }
  char org = '?';
  for (auto i : g) {
    if (i.second.size() > 2) {
      cout << "NO\n";
      return;
    }
    if (i.second.size() == 1) org = i.first;
  }
  string out;
  function<void(char)> dfs = [&](char r) {
    vs[r - 'a'] = 0;
    out.push_back(r);
    for (auto i : g[r]) {
      if (vs[i - 'a']) {
        dfs(i);
      }
    }
  };
  if (org != '?') dfs(org);
  for (auto i : vs) {
    if (i == 1) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
  cout << out;
  for (char i = 'a'; i <= 'z'; i++) {
    if (!v1[i - 'a']) cout << i;
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) solve();
  return 0;
}
