#include <bits/stdc++.h>
using namespace std;
int t;
bool isbeside(string k, char c, int& cur) {
  if (cur + 1 < k.length() && k[cur + 1] == c) {
    cur++;
    return true;
  }
  if (cur > 0 && k[cur - 1] == c) {
    cur--;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  string s;
  while (t--) {
    string keyboard = "";
    int inkeyboard[30];
    memset(inkeyboard, 0, sizeof(inkeyboard));
    cin >> s;
    keyboard += s[0];
    inkeyboard[s[0] - 'a'] = 1;
    int cur = 0;
    bool flag = true;
    for (int i = 1; i < s.length(); ++i) {
      if (isbeside(keyboard, s[i], cur)) {
        continue;
      } else {
        if (cur == keyboard.length() - 1 || cur == 0) {
          if (inkeyboard[s[i] - 'a']) {
            flag = false;
            break;
          } else {
            if (cur == 0)
              keyboard = s[i] + keyboard;
            else {
              keyboard = keyboard + s[i];
              cur++;
            }
            inkeyboard[s[i] - 'a'] = 1;
          }
        } else {
          flag = false;
          break;
        }
      }
    }
    if (flag) {
      cout << "YES" << endl;
      for (int i = 0; i < 26; ++i) {
        if (!inkeyboard[i]) {
          keyboard += ('a' + i);
        }
      }
      cout << keyboard << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
