#include <bits/stdc++.h>
using namespace std;
void swap(long long &a, long long &b) {
  a = a + b;
  b = a - b;
  a -= b;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<bool> seive(long long n) {
  vector<bool> toret(n, true);
  toret[1] = false;
  for (long long i = 2; i * i <= n; i++) {
    if (toret[i]) {
      for (long long j = i * i; j <= n; j += i) toret[j] = false;
    }
  }
  return toret;
}
long long expo(long long x, long long y, long long mod = -1) {
  long long res = 1;
  if (mod == -1) {
    while (y > 0) {
      if (y & 1) res *= x;
      y /= 2;
      x *= x;
    }
  } else {
    x %= mod;
    while (y > 0) {
      if (y & 1) res = (res * x) % mod;
      y /= 2;
      x = (x * x) % mod;
    }
  }
  return res;
}
long long fact(long long n, long long mod = -1) {
  long long ans = 1;
  if (mod == -1) {
    for (long long i = 1; i < n + 1; i++) ans *= i;
  } else {
    for (long long i = 1; i < n + 1; i++) {
      ans *= i % mod;
      ans %= mod;
    }
  }
  return ans;
}
long long comb(long long n, long long r, long long mod = -1) {
  long long ans = 1;
  if (mod == -1) {
    for (long long i = 0; i < r; i++) {
      ans *= (n - i);
      ans /= (i + 1);
    }
  } else {
    vector<long long> C(r + 1, 1);
    for (long long i = 2; i <= n; i++) {
      for (long long j = min(i - 1, r); j >= 1; j--)
        C[j] = (C[j] + C[j - 1]) % mod;
    }
    ans = C[r];
  }
  return ans;
}
void solve() {
  string s;
  cin >> s;
  vector<long long> adj[26];
  set<pair<char, char>> done;
  if (s.length() == 1) {
    cout << "YES\n";
    cout << "abcdefghijklmnopqrstuvwxyz\n";
    return;
  }
  for (long long i = 1; i < s.length(); i++) {
    char a = min(s[i], s[i - 1]), b = max(s[i], s[i - 1]);
    if (done.find({a, b}) != done.end() || a == b) continue;
    done.insert({a, b});
    adj[s[i] - 'a'].push_back(s[i - 1] - 'a');
    adj[s[i - 1] - 'a'].push_back(s[i] - 'a');
  }
  vector<bool> vis(26, 0);
  string ans;
  bool tr = false;
  long long ind;
  for (long long i = 0; i < 26; i++) {
    if (adj[i].size() == 1) {
      tr = true;
      ind = i;
      break;
    }
  }
  if (!tr) {
    cout << "NO\n";
    return;
  }
  vis[ind] = true;
  stack<long long> df;
  vector<long long> par(26, -1);
  par[ind] = -1;
  df.push(ind);
  while (!df.empty()) {
    long long cur = df.top();
    ans.push_back(cur + 'a');
    df.pop();
    if (adj[cur].size() > 2) {
      cout << "NO\n";
      return;
    }
    for (long long j = 0; j < adj[cur].size(); j++) {
      long long v = adj[cur][j];
      if (!vis[v]) {
        par[v] = cur;
        vis[v] = true;
        df.push(v);
      } else if (v != par[cur]) {
        cout << "NO\n";
        return;
      }
    }
  }
  for (long long i = 0; i < 26; i++) {
    if (!vis[i]) ans.push_back(i + 'a');
  }
  cout << "YES\n";
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
