#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long n = s.size();
  list<char> ans;
  long long prv_pos = -1;
  vector<long long> place(26, -1);
  long long placed = 0;
  for (long long i = 0; i < n; i++) {
    long long curr_pos = i;
    if (place[s[i] - 'a'] != -1) {
      curr_pos = place[s[i] - 'a'];
      long long dif = abs(curr_pos - prv_pos);
      if (dif != 1) {
        cout << "NO\n";
        return;
      }
    }
    if (place[s[i] - 'a'] == -1) {
      if (prv_pos != 0 && prv_pos != placed - 1) {
        cout << "NO\n";
        return;
      }
      if (prv_pos == 0) {
        ans.push_front(s[i]);
        for (auto &it : place) {
          if (it + 1) {
            it++;
          }
        }
        place[s[i] - 'a'] = 0;
      } else {
        ans.push_back(s[i]);
        place[s[i] - 'a'] = placed;
      }
      placed++;
      prv_pos = place[s[i] - 'a'];
    } else {
      prv_pos = curr_pos;
    }
  }
  for (long long i = 0; i < 26; i++) {
    if (place[i] == -1) {
      ans.push_back(i + 'a');
    }
  }
  cout << "YES\n";
  for (auto &it : ans) {
    cout << it;
  }
  cout << '\n';
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
