#include <bits/stdc++.h>
using namespace std;
vector<bool> prime(90000002, true);
void Sieve() {
  for (int p = 2; p * p <= 90000001; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 90000001; i += p) prime[i] = false;
    }
  }
}
pair<long long, long long> func(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    long long tmp;
    if (n % i == 0) {
      tmp = n / i;
      if (tmp != i) return {i, tmp};
    }
  }
  return {-1, -1};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tests = 1;
  cin >> tests;
  while (tests--) {
    long long n, i;
    string s, ans, tmp = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;
    n = s.length();
    bool flag = true;
    map<char, long long> pos;
    ans.push_back(s[0]);
    pos[s[0]] = 0;
    for (i = 0; i < n - 1; i++) {
      char a = s[i], b = s[i + 1];
      long long val = pos[a];
      if (pos.find(b) != pos.end()) {
        bool f = false;
        if ((val > 0 && pos[b] == val - 1) || pos[b] == val + 1) f = true;
        if (!f) {
          flag = false;
          break;
        }
      } else {
        if (val == 0) {
          string ss;
          ss.push_back(b);
          ans = ss + ans;
          for (auto &x : pos) x.second++;
          pos[b] = 0;
        } else if (ans.length() - 1 > val) {
          flag = false;
          break;
        } else {
          ans.push_back(b);
          pos[b] = val + 1;
        }
      }
    }
    if (!flag) {
      cout << "NO"
           << "\n";
      continue;
    }
    for (auto x : tmp) {
      if (pos.find(x) == pos.end()) ans.push_back(x);
    }
    cout << "YES"
         << "\n";
    cout << ans << "\n";
  }
  return 0;
}
