#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int cases;
  cin >> cases;
  while (cases--) {
    string s;
    cin >> s;
    pair<char, char> alpha[26];
    for (int i = 0; i < 26; i++) {
      alpha[i].first = alpha[i].second = -1;
    }
    char leftMost = s[0];
    int len = s.size();
    bool isPossible = true;
    bool isPrinted[26];
    memset(isPrinted, false, sizeof(isPrinted));
    for (int i = 0; i < len - 1; i++) {
      char cur = s[i] - 'a';
      isPrinted[cur] = true;
      char next = s[i + 1];
      if (alpha[cur].first == next || alpha[cur].second == next)
        continue;
      else if (isPrinted[next - 'a']) {
        isPossible = false;
        break;
      } else if (alpha[cur].first != -1 && alpha[cur].second != -1) {
        isPossible = false;
        break;
      } else if (alpha[cur].first == -1) {
        alpha[cur].first = next;
        alpha[next - 'a'].second = cur + 'a';
        if (leftMost == s[i]) leftMost = next;
      } else if (alpha[cur].second == -1) {
        alpha[cur].second = next;
        alpha[next - 'a'].first = cur + 'a';
      } else {
        isPossible = false;
        break;
      }
    }
    if (isPossible) {
      cout << "YES" << endl;
      while (leftMost != -1) {
        cout << leftMost;
        isPrinted[leftMost - 'a'] = true;
        leftMost = alpha[leftMost - 'a'].second;
      }
      for (int i = 0; i < 26; i++) {
        if (!isPrinted[i]) {
          char c = i + 'a';
          cout << c;
        }
      }
      cout << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
