#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long temp;
long long ans[26][3 * 26];
long long p, q, si;
vector<long long> buffer(26);
vector<long long> a[26];
long long settle(long long ap, long long first) {
  if (first == 1) {
    long long flag = 0;
    for (long long i = 0; i < a[ap].size(); i++) {
      if (buffer[a[ap][i]] == 0) {
        flag = 1;
        ans[p][q] = a[ap][i];
        buffer[a[ap][i]] = q;
        q++;
        settle(a[ap][i], 1);
      } else {
        if (buffer[a[ap][i]] != q - 2) return 1;
      }
    }
    return 0;
  } else {
    long long flag = 0;
    for (long long i = 0; i < a[ap].size(); i++) {
      if (buffer[a[ap][i]] == 0) {
        flag = 1;
        ans[p][si] = a[ap][i];
        buffer[a[ap][i]] = si;
        si--;
        settle(a[ap][i], 0);
      } else {
        if (buffer[a[ap][i]] != si + 2) return 1;
      }
    }
    return 0;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    s.push_back('/');
    s = "/" + s;
    long long arr[27][27];
    for (long long i = 0; i < 27; i++) {
      for (long long j = 0; j < 27; j++) arr[i][j] = 0;
    }
    for (long long i = 1; i < s.size() - 1; i++) {
      if ((s[i + 1]) >= 'a' && (s[i + 1]) <= 'z') {
        arr[s[i] - 'a'][s[i + 1] - 'a'] = 1;
      }
      if ((s[i - 1]) >= 'a' && (s[i - 1]) <= 'z') {
        arr[s[i] - 'a'][s[i - 1] - 'a'] = 1;
      }
    }
    long long flag = 1;
    for (long long i = 0; i < 26; i++) {
      a[i].clear();
    }
    for (long long i = 0; i < 26; i++) {
      temp = 0;
      for (long long j = 0; j < 26; j++) {
        if (arr[i][j] == 1) {
          a[i].push_back(j);
          temp++;
        }
      }
      if (temp > 2) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) {
      cout << "NO" << '\n';
      continue;
    }
    flag = 0;
    for (long long i = 0; i < 26; i++) {
      for (long long j = 0; j < 3 * 26; j++) {
        ans[i][j] = -1;
      }
    }
    for (long long i = 0; i < 26; i++) buffer[i] = 0;
    p = -1, q = 39, si = 38;
    for (long long i = 0; i < 26; i++) {
      if (a[i].size() == 2) {
        if (buffer[i] == 0) {
          p++;
          q = 39, si = 38;
          ans[p][q] = i;
          buffer[i] = q;
          q++;
          ans[p][q] = a[i][0];
          buffer[a[i][0]] = q;
          q++;
          flag = settle(a[i][0], 1);
          ans[p][si] = a[i][1];
          buffer[a[i][1]] = si;
          si--;
          flag = settle(a[i][1], 0);
        }
      } else if (a[i].size() == 1) {
        if (buffer[i] == 0) {
          p++;
          q = 39, si = 38;
          ans[p][q] = i;
          buffer[i] = q;
          q++;
          ans[p][q] = a[i][0];
          buffer[a[i][0]] = q;
          q++;
          flag = settle(a[i][0], 1);
        }
      }
    }
    vector<long long> fans;
    for (long long i = 0; i < 26; i++) {
      for (long long j = 0; j < 3 * 26; j++) {
        if (ans[i][j] != -1) fans.push_back(ans[i][j]);
      }
    }
    for (long long i = 0; i < 26; i++) {
      if (buffer[i] == 0) fans.push_back(i);
    }
    if (flag == 1) {
      cout << "NO" << '\n';
      continue;
    }
    cout << "YES" << '\n';
    for (long long i = 0; i < fans.size(); i++) cout << char(fans[i] + 'a');
    cout << '\n';
  }
  return 0;
}
