#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int n, long long int p) {
  if (p == 0) return 1;
  long long int x = pow1(n, p / 2);
  x = (x * x) % 1000000007;
  if (p % 2 == 0)
    return x;
  else
    return (x * n) % 1000000007;
}
string ans = "";
long long int flg = 0;
void dfs(long long int e, vector<set<long long int>> &v, long long int par,
         string &s, vector<long long int> &vis) {
  s += (char)(e + 97);
  vis[e] = 1;
  ans = s;
  long long int c = 0;
  long long int c1 = 0;
  for (auto i : v[e]) {
    if (vis[i] == 1) c1++;
  }
  if (c1 >= 2) {
    flg = 1;
    return;
  }
  for (auto i : v[e]) {
    if (i != par) dfs(i, v, e, s, vis);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  for (long long int i = 0; i < t; i++) {
    string s;
    cin >> s;
    long long int n = s.size();
    if (n == 1) {
      cout << "YES"
           << "\n";
      cout << s[0];
      for (long long int i = 0; i < 26; i++) {
        if (i != s[0] - 97) {
          cout << (char)(i + 97);
        }
      }
      cout << "\n";
      continue;
    }
    vector<set<long long int>> v(27);
    for (long long int i = 0; i < (long long int)s.size(); i++) {
      if (i != 0) {
        v[s[i] - 97].insert(s[i - 1] - 97);
      }
      if (i != n - 1) {
        v[s[i] - 97].insert(s[i + 1] - 97);
      }
    }
    long long int e = -1;
    long long int c = 0;
    long long int f = 0;
    for (long long int i = 0; i < 26; i++) {
      if ((long long int)v[i].size() == 1) {
        e = i;
        c++;
      } else if ((long long int)v[i].size() >= 3) {
        f = 1;
        break;
      }
    }
    if (c < 2 || f == 1) {
      cout << "NO"
           << "\n";
      continue;
    }
    string ans = "";
    queue<long long int> q;
    q.push(e);
    vector<long long int> vis(26, 0);
    while (q.size() > 0) {
      long long int x = q.front();
      vis[x]++;
      q.pop();
      ans += (char)(x + 97);
      for (auto i : v[x]) {
        if (vis[i] == 0) q.push(i);
      }
    }
    for (long long int i = 0; i < 26; i++) {
      if (vis[i] == 0) ans += (char)(i + 97);
    }
    cout << "YES"
         << "\n";
    cout << ans << "\n";
  }
  return 0;
}
