#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 300005;
const long long inf = 10000000000000000;
void print(vector<long long> v) {
  long long i;
  for (i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
vector<long long> read(long long n) {
  long long i;
  vector<long long> arr(n, 0);
  for (i = 0; i < n; i++) cin >> arr[i];
  return arr;
}
vector<long long> read(long long n, long long k) {
  long long i;
  vector<long long> arr(n + k, 0);
  for (i = k; i < n + k; i++) cin >> arr[i];
  return arr;
}
bool isEven(long long n) { return n % 2 == 0; }
bool isOdd(long long n) { return n % 2 != 0; }
vector<char> ans;
void topo(long long cur, vector<long long> adj[], vector<bool> &vis) {
  vis[cur] = 1;
  ans.push_back(char('a' + cur));
  for (auto next : adj[cur]) {
    if (!vis[next]) {
      topo(next, adj, vis);
    }
  }
}
void solve() {
  long long t;
  cin >> (t);
  while (t--) {
    long long i, j, k, n, m, p, q, x, y, a, b, l, r;
    string str;
    cin >> str;
    n = str.size();
    set<char> check;
    for (i = 0; i < n; i++) {
      check.insert(str[i]);
    }
    if (check.size() == 1) {
      cout << "YES\n";
      for (i = 0; i < 26; i++) {
        cout << char(i + 'a');
      }
      cout << "\n";
      continue;
    }
    vector<long long> in(26, 0);
    vector<long long> adj[26];
    for (i = 0; i < n - 1; i++) {
      if (find(adj[str[i + 1] - 'a'].begin(), adj[str[i + 1] - 'a'].end(),
               str[i] - 'a') == adj[str[i + 1] - 'a'].end() &&
          str[i + 1] != str[i]) {
        adj[str[i + 1] - 'a'].push_back(str[i] - 'a');
        adj[str[i] - 'a'].push_back(str[i + 1] - 'a');
        in[str[i] - 'a']++;
        in[str[i + 1] - 'a']++;
      }
    }
    long long ct1 = 0, ct2 = 0, ct0 = 0;
    bool ok = 1;
    for (i = 0; i < 26; i++) {
      if (in[i] == 1) {
        ct1++;
      } else if (in[i] == 2) {
        ct2++;
      } else if (in[i] == 0) {
        ct0++;
      }
    }
    if (ct1 + ct2 + ct0 != 26 || ct1 != 2) {
      cout << "NO\n";
      continue;
    }
    vector<bool> vis(26, 0);
    cout << "YES\n";
    ans.clear();
    for (i = 0; i < 26; i++) {
      if (!vis[i] && adj[i].size() == 1) {
        topo(i, adj, vis);
        break;
      }
    }
    for (i = 0; i < ans.size(); i++) {
      cout << ans[i];
    }
    for (i = 0; i < 26; i++) {
      if (!vis[i]) {
        cout << char('a' + i);
      }
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  long long i, j, k, n, m, p, q, x, y, a, b, l, r;
  return 0;
}
