#include <bits/stdc++.h>
using namespace std;
const int maxm = 210;
int T, now;
char str[maxm], c[100], *key = c + 50;
bool flag = true;
set<char> s;
bool null(int x) { return key[x] == '\0'; }
int check(char ch, int pos) {
  if (key[pos - 1] == ch)
    return -1;
  else if (key[pos + 1] == ch)
    return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> T;
  while (T--) {
    cin >> str;
    for (char a = 'a'; a <= 'z'; ++a) s.insert(a);
    for (int i = 0, res; str[i]; ++i) {
      if (null(now)) {
        key[now] = str[i];
        s.erase(str[i]);
        continue;
      }
      res = check(str[i], now);
      if (res != 0) {
        now += res;
      } else {
        if (null(now - 1) && s.find(str[i]) != s.end()) {
          key[now - 1] = str[i];
          s.erase(str[i]);
          now--;
        } else if (null(now + 1) && s.find(str[i]) != s.end()) {
          key[now + 1] = str[i];
          s.erase(str[i]);
          now++;
        } else {
          flag = false;
          break;
        }
      }
    }
    cout << (flag ? "YES\n" : "NO\n");
    if (flag) {
      while (!null(now)) --now;
      cout << (key + now + 1);
      for (char c : s) cout << c;
      cout << endl;
    }
    now = 0;
    memset(c, 0, sizeof c);
    flag = true;
  }
}
