#include <bits/stdc++.h>
using namespace std;
long long grph[26][26];
long long vis[30] = {0};
string ans;
void dfs(long long a) {
  if (vis[a] == 0) {
    vis[a] = 1;
    char c1 = 'a';
    c1 += a;
    cout << c1;
    for (long long i = 0; i < 26; i++) {
      if (grph[a][i] == 1) dfs(i);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    for (long long i = 0; i < 26; i++) {
      for (long long j = 0; j < 26; j++) {
        grph[i][j] = 0;
      }
    }
    long long n = s.size();
    long long f[26] = {0};
    long long c[220] = {0};
    long long flag = 0;
    ans = "";
    for (long long i = 0; i <= 29; i++) vis[i] = 0;
    for (long long i = 0; i < (n - 1); i++) {
      if (grph[s[i] - 'a'][s[i + 1] - 'a'] == 0) {
        f[s[i] - 'a']++;
        f[s[i + 1] - 'a']++;
        c[f[s[i] - 'a']]++;
        c[f[s[i + 1] - 'a']]++;
        c[f[s[i] - 'a'] - 1]--;
        c[f[s[i + 1] - 'a'] - 1]--;
      }
      grph[s[i] - 'a'][s[i + 1] - 'a'] = 1;
      grph[s[i + 1] - 'a'][s[i] - 'a'] = 1;
    }
    for (long long i = 3; i <= 200; i++) {
      if (c[i] != 0) flag++;
    }
    if (c[1] < 2) flag++;
    if (flag != 0 && n != 1) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
      for (long long j = 0; j < 26; j++) {
        for (long long i = 0; i < 26; i++) {
          if (f[i] == 1) {
            if (vis[i] == 0) {
              dfs(i);
            }
          }
        }
      }
      for (long long i = 0; i < 26; i++) {
        if (vis[i] == 0) {
          char c1 = 'a';
          c1 += i;
          cout << c1;
        }
      }
      cout << "\n";
    }
  }
}
