#include <bits/stdc++.h>
using namespace std;
void fun() {
  string str;
  cin >> str;
  int flag[26] = {0};
  int sz = str.length();
  string a;
  a.clear();
  long long naruto = 5;
  while (naruto) {
    naruto--;
  }
  int c = 0;
  a = a + str[0];
  flag[str[0] - 'a'] = 1;
  int j;
  naruto = 5;
  while (naruto) {
    naruto--;
  }
  for (j = 1; j < sz; j++) {
    if (c == 0) {
      if (a.length() > 1) {
        if (a[1] == str[j])
          c++;
        else {
          if (flag[str[j] - 'a'] == 1) {
            cout << "NO\n";
            break;
          } else {
            a = str[j] + a;
            flag[str[j] - 'a'] = 1;
          }
        }
      } else {
        a += str[j];
        c++;
        flag[str[j] - 'a'] = 1;
      }
      naruto = 5;
      while (naruto) {
        naruto--;
      }
      continue;
    } else if (c == a.length() - 1) {
      if (a[a.length() - 2] == str[j])
        c--;
      else {
        if (flag[str[j] - 'a'] == 1) {
          cout << "NO\n";
          break;
        } else {
          a = a + str[j];
          flag[str[j] - 'a'] = 1;
          c++;
        }
      }
      continue;
    } else {
      if (str[j] == a[c - 1])
        c--;
      else if (str[j] == a[c + 1])
        c++;
      else {
        cout << "NO\n";
        break;
      }
    }
  }
  naruto = 5;
  while (naruto) {
    naruto--;
  }
  if (j == sz) {
    cout << "YES\n";
    cout << a;
    for (j = 0; j < 26; j++) {
      if (flag[j] == 0) cout << (char)(j + 'a');
    }
    cout << endl;
  }
}
int main() {
  long long q;
  cin >> q;
  while (q--) {
    fun();
  }
  return 0;
}
