#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
void test_case() {
  string s;
  cin >> s;
  vector<bool> used(26);
  string t;
  t += s[0];
  used[s[0] - 'a'] = 1;
  long long pos = 0;
  for (long long i = 1; i < (long long)((s).size()); i++) {
    if (used[s[i] - 'a']) {
      if (pos > 0 && t[pos - 1] == s[i])
        pos--;
      else if (pos < (long long)((t).size()) - 1 && t[pos + 1] == s[i])
        pos++;
      else {
        cout << "NO\n";
        return;
      }
    } else {
      if (pos == 0) {
        t = s[i] + t;
      } else if (pos == (long long)((t).size()) - 1) {
        t += s[i];
        pos = (long long)((t).size()) - 1;
      } else {
        cout << "NO\n";
        return;
      }
    }
    used[s[i] - 'a'] = 1;
  }
  for (long long i = 0; i < 26; i++) {
    if (!used[i]) t += (i + 'a');
  }
  cout << "YES\n" << t << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    test_case();
  }
  return 0;
}
