#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    vector<char> keyboard(26 + 26 + 26);
    int curl = 26 + 13, curr = curl, curid = curl;
    vector<bool> used(26);
    string s;
    cin >> s;
    bool flag = true;
    for (auto &c : s) {
      if (!used[c - 'a']) {
        used[c - 'a'] = true;
        if (curid == curl) {
          keyboard[--curl] = c;
          --curid;
        } else if (curid + 1 == curr) {
          keyboard[curr++] = c;
          ++curid;
        } else {
          flag = false;
          break;
        }
      } else {
        if (keyboard[curid - 1] == c) {
          curid--;
        } else if (keyboard[curid + 1] == c) {
          curid++;
        } else {
          flag = false;
          break;
        }
      }
    }
    for (int i = 0; i < 26; i++) {
      if (!used[i]) {
        keyboard[curr++] = i + 'a';
      }
    }
    if (!flag) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
      for (int i = curl; i < curr; i++) {
        cout << keyboard[i];
      }
      cout << '\n';
    }
  }
  return 0;
}
