#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long p = 998244353;
long long int fac[200005];
long long int power(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long int mod(long long int x) {
  if (x < 0)
    return -x;
  else
    return x;
}
long long int inverse(long long int a, long long int p) {
  return power(a, p - 2, p);
}
long long int ncr(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
vector<long long int> visited;
vector<vector<long long int> > adj;
void dfs(long long int s, long long int check) {
  if (visited[s] == 1) return;
  if (check) cout << char(s + 'a');
  visited[s] = 1;
  for (long long int i = (0); i <= ((long long int)(adj[s].size()) - 1); i++) {
    if (!visited[adj[s][i]]) {
      dfs(adj[s][i], check);
    }
  }
}
signed main() {
  long long int t;
  cin >> t;
  ;
  while (t--) {
    long long int m = 26;
    string s;
    cin >> s;
    visited.resize(m);
    adj.resize(m);
    for (long long int i = (0); i <= (25); i++) visited[i] = 0;
    long long int n = s.size();
    if (n == 1) {
      cout << "YES" << '\n';
      for (long long int j = (0); j <= (25); j++) cout << char(j + 'a');
      cout << '\n';
    } else {
      for (long long int i = (0); i <= (n - 2); i++) {
        long long int check = 1;
        for (long long int j = (0);
             j <= ((long long int)(adj[s[i] - 'a'].size()) - 1); j++) {
          if (adj[s[i] - 'a'][j] == s[i + 1] - 'a') check = 0;
        }
        if (check) {
          adj[s[i] - 'a'].push_back(s[i + 1] - 'a');
          adj[s[i + 1] - 'a'].push_back(s[i] - 'a');
        }
      }
      long long int present[26] = {0};
      long long int check = 1;
      for (long long int i = (0); i <= (n - 1); i++) {
        if ((long long int)(adj[s[i] - 'a'].size()) > 2) check = 0;
        present[s[i] - 'a'] = 1;
      }
      if (!check)
        cout << "NO" << '\n';
      else {
        vector<long long int> leaves;
        for (long long int i = (0); i <= (n - 1); i++) {
          if ((long long int)(adj[s[i] - 'a'].size()) == 1) {
            long long int flag = 1;
            for (long long int j = (0);
                 j <= ((long long int)(leaves.size()) - 1); j++) {
              if (leaves[j] == s[i] - 'a') flag = 0;
            }
            if (flag) leaves.push_back(s[i] - 'a');
          }
        }
        long long int zero = 0;
        for (long long int i = (0); i <= ((long long int)(leaves.size()) - 1);
             i++) {
          if (!visited[leaves[i]]) dfs(leaves[i], zero);
        }
        long long int check = 1;
        for (long long int i = (0); i <= (25); i++) {
          if (present[i] && !visited[i]) check = 0;
        }
        if (!check)
          cout << "NO" << '\n';
        else {
          cout << "YES" << '\n';
          for (long long int i = (0); i <= (25); i++) visited[i] = 0;
          long long int one = 1;
          for (long long int i = (0); i <= ((long long int)(leaves.size()) - 1);
               i++) {
            if (!visited[leaves[i]]) dfs(leaves[i], one);
          }
          for (long long int i = (0); i <= (25); i++)
            if (!visited[i]) cout << char(i + 'a');
          cout << '\n';
        }
        leaves.clear();
      }
    }
    visited.clear();
    adj.clear();
  }
}
