#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  string s;
  int flag;
  while (t--) {
    flag = 1;
    cin >> s;
    vector<bool> used(26);
    used[s[0] - 'a'] = true;
    string t(1, s[0]);
    int pos = 0;
    for (int i = 1; i < s.size(); i++) {
      if (used[s[i] - 'a']) {
        if (pos > 0 && t[pos - 1] == s[i]) {
          pos--;
        } else if (pos + 1 < t.size() && t[pos + 1] == s[i]) {
          pos++;
        } else {
          cout << "NO" << endl;
          flag = 0;
          break;
        }
      } else {
        if (pos == 0)
          t = s[i] + t;
        else if (pos == t.size() - 1) {
          t += s[i];
          pos++;
        } else {
          cout << "NO" << endl;
          flag = 0;
          break;
        }
        used[s[i] - 'a'] = true;
      }
    }
    if (flag) {
      for (int i = 0; i < 26; i++) {
        if (!used[i]) t += char(i + 'a');
      }
      cout << "YES" << endl << t << endl;
    }
  }
  return 0;
}
