#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    string s;
    cin >> s;
    vector<bool> vis(26);
    vector<char> lay(600, '-');
    bool pos = 1;
    for (int i = 0, index = 300; i < s.size() and pos; ++i) {
      if (lay[index] == '-') {
        lay[index] = s[i];
        vis[s[i] - 'a'] = 1;
        continue;
      }
      if (lay[index] == s[i])
        pos = 0;
      else {
        if (lay[index + 1] == s[i]) {
          ++index;
        } else if (lay[index - 1] == s[i]) {
          --index;
        } else if (vis[s[i] - 'a']) {
          pos = 0;
        } else if (lay[index + 1] == '-') {
          lay[index + 1] = s[i];
          vis[s[i] - 'a'] = 1;
          index++;
        } else if (lay[index - 1] == '-') {
          lay[index - 1] = s[i];
          vis[s[i] - 'a'] = 1;
          index--;
        } else {
          pos = 0;
        }
      }
    }
    if (pos) {
      printf("YES\n");
      for (int i = 0; i < 600; ++i) {
        if (lay[i] != '-') printf("%c", lay[i]);
      }
      for (int i = 0; i < 26; ++i) {
        if (!vis[i]) printf("%c", i + 'a');
      }
      printf("\n");
    } else {
      printf("NO\n");
    }
  }
}
