#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long INF = 1e12;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string a;
    cin >> a;
    bool b = 0;
    string ans = "";
    ans.append(1, a[0]);
    map<char, long long> m;
    m[a[0]] = 0;
    map<char, long long>::iterator it;
    for (long long i = 0; i < a.size() - 1; i++) {
      if (m.count(a[i]) && m.count(a[i + 1]) && abs(m[a[i]] - m[a[i + 1]]) == 1)
        continue;
      else if (m[a[i]] == ans.size() - 1 && m.count(a[i + 1]) == 0) {
        m[a[i + 1]] = ans.size();
        ans.append(1, a[i + 1]);
      } else if (m[a[i]] == 0 && m.count(a[i + 1]) == 0) {
        for (it = m.begin(); it != m.end(); it++) it->second++;
        ans.insert(0, 1, a[i + 1]);
        m[a[i + 1]] = 0;
      } else {
        b = 1;
        break;
      }
    }
    if (b)
      cout << "NO" << '\n';
    else {
      cout << "YES" << '\n' << ans;
      ;
      vector<long long> h(26, 0);
      for (long long i = 0; i < ans.size(); i++) h[ans[i] - 'a']++;
      for (long long i = 0; i < 26; i++)
        if (!h[i]) cout << char('a' + i);
      cout << '\n';
    }
  }
  return 0;
}
