#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int tt;
  cin >> tt;
  while (tt--) {
    string a;
    set<long long int> s[26];
    vector<long long int> ans;
    long long int n, one = 0, two = 0, c = 0, id = 0;
    cin >> a;
    n = (long long int)a.size();
    if (n == 1) {
      cout << "YES\n";
      for (long long int i = 0; i <= 25; i++) {
        char c = i + 'a';
        cout << c;
      }
      cout << endl;
      continue;
    }
    for (long long int i = 1; i <= n - 1; i++)
      s[a[i] - 'a'].insert(a[i - 1] - 'a');
    for (long long int i = 0; i <= n - 2; i++)
      s[a[i] - 'a'].insert(a[i + 1] - 'a');
    for (long long int i = 0; i <= 25; i++)
      if ((long long int)s[i].size() != 0) {
        if ((long long int)s[i].size() == 1) {
          one++;
          id = i;
        } else if ((long long int)s[i].size() == 2)
          two++;
        else
          c++;
      }
    if (c > 0 || one != 2)
      cout << "NO\n";
    else {
      cout << "YES\n";
      queue<long long int> q;
      bool vis[26];
      for (long long int i = 0; i <= 25; i++) vis[i] = false;
      q.push(id);
      ans.push_back(id);
      vis[id] = true;
      while (!q.empty()) {
        long long int x = q.front(), y, z;
        q.pop();
        for (auto i : s[x]) {
          if (!vis[i]) {
            ans.push_back(i);
            vis[i] = true;
            q.push(i);
          }
        }
      }
      for (long long int i = 0; i <= 25; i++) vis[i] = false;
      for (long long int i = 0; i <= (long long int)ans.size() - 1; i++) {
        char c = ans[i] + 'a';
        cout << c;
        vis[ans[i]] = true;
      }
      for (long long int i = 0; i <= 25; i++) {
        if (!vis[i]) {
          char c = i + 'a';
          cout << c;
        }
      }
      cout << endl;
    }
  }
}
