#include <bits/stdc++.h>
using namespace std;
struct sans {
  long long int t1;
  long long int b1;
};
bool func(sans s1, sans s2) { return s1.t1 < s2.t1; }
long long int qw[2 * 100000 + 1];
pair<long long int, long long int> s1[2 * 100000 + 1];
int main() {
  long long int t, n, i, j;
  string s1, s2;
  cin >> t;
  while (t--) {
    cin >> s1;
    long long int flag = 0, flag1 = 0;
    n = s1.length();
    s2 = "";
    s2 = s2 + s1[0];
    for (i = 1; i <= n - 1; i++) {
      long long int j;
      long long int flag = 0;
      for (j = 0; j <= s2.length() - 1; j++) {
        if (s1[i] == s2[j]) {
          flag = 1;
          break;
        }
      }
      if (flag == 1) {
        if (s1[i - 1] == s2[j + 1] || s1[i - 1] == s2[j - 1]) {
          continue;
        } else {
          flag1 = 1;
          cout << "NO" << endl;
          break;
        }
      } else {
        long long int j;
        for (j = 0; j <= s2.length() - 1; j++) {
          if (s1[i - 1] == s2[j]) {
            break;
          }
        }
        if (j == 0) {
          s2 = s1[i] + s2;
        } else if (j == s2.length() - 1) {
          s2 = s2 + s1[i];
        } else {
          flag1 = 1;
          cout << "NO" << endl;
          break;
        }
      }
    }
    if (flag1 == 0) {
      cout << "YES" << endl;
      long long int a1[27];
      for (long long int i = 0; i <= 27; i++) a1[i] = 0;
      ;
      for (long long int j = 0; j < s2.length(); j++) {
        a1[s2[j] - 'a'] = 1;
      }
      for (long long int i = 0; i < 26; i++) {
        if (a1[i] == 0) {
          long long int qw = i + 'a';
          char x = qw;
          s2 = s2 + x;
        }
      }
      cout << s2 << endl;
    }
  }
}
