#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
void yesNo(long long n, long long x = 0) {
  if (x == 0)
    cout << (n ? "YES\n" : "NO\n");
  else {
    cout << (n ? "Yes\n" : "No\n");
  }
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A>
ostream &operator<<(ostream &cout, set<A> const &s);
template <typename A, typename B>
ostream &operator<<(ostream &cout, map<A, B> const &m);
template <typename A>
ostream &operator<<(ostream &cout, multiset<A> const &s);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (long long i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A>
ostream &operator<<(ostream &cout, set<A> const &s) {
  cout << "[";
  int i = 0;
  for (auto val : s) {
    if (i) cout << ", ";
    cout << val;
    i++;
  }
  return cout << "]";
}
template <typename A>
ostream &operator<<(ostream &cout, multiset<A> const &s) {
  cout << "[";
  int i = 0;
  for (auto val : s) {
    if (i) cout << ", ";
    cout << val;
    i++;
  }
  return cout << "]";
}
template <typename A, typename B>
ostream &operator<<(ostream &cout, map<A, B> const &m) {
  cout << "[";
  int i = 0;
  for (auto val : m) {
    if (i) cout << ", ";
    cout << val;
    i++;
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
const long long mod = 1e9 + 7;
const long long N = 1e5;
const long long MAX = LLONG_MAX;
const long long modulo = 998244353;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
long long f, n, m, k, q, l, r, x, y, z, ans, cnt;
void solve(int te) {
  f = ans = 0;
  cnt = 0;
  x = y = z = 0;
  string s;
  cin >> s;
  n = (long long)((s).size());
  std::vector<set<char>> v(26);
  for (long long i = 0; i < n; i++) {
    if (i + 1 < n) v[s[i] - 'a'].insert(s[i + 1]);
    if (i - 1 >= 0) v[s[i] - 'a'].insert(s[i - 1]);
  }
  string x;
  int i = s[0] - 'a';
  x += s[0];
  while (1) {
    if ((long long)((v[i]).size())) {
      if ((long long)((v[i]).size()) > 2) {
        yesNo(0);
        return;
      }
      auto it = v[i].begin();
      x += *it;
      y = i;
      i = *it - 'a';
      v[y].erase(it);
      v[i].erase(char('a' + y));
    } else {
      break;
    }
  }
  reverse((x).begin(), (x).end());
  i = x.back() - 'a';
  while (1) {
    if ((long long)((v[i]).size())) {
      if ((long long)((v[i]).size()) > 2) {
        yesNo(0);
        return;
      }
      auto it = v[i].begin();
      x += *it;
      y = i;
      i = *it - 'a';
      v[y].erase(it);
      v[i].erase(char('a' + y));
    } else {
      break;
    }
  }
  std::vector<long long> st(26);
  for (long long i = 0; i < (long long)((x).size()); i++) {
    if (st[x[i] - 'a']) {
      yesNo(0);
      return;
    }
    st[x[i] - 'a']++;
  }
  for (long long i = 0; i < 26; i++) {
    if (!st[i] and (long long)((v[i]).size())) {
      yesNo(0);
      return;
    }
  }
  yesNo(1);
  cout << x;
  for (long long i = 0; i < 26; i++) {
    if (!st[i]) {
      cout << char('a' + i);
    }
  }
  cout << "\n";
}
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(NULL);
  ;
  int t = 1;
  std::cin >> t;
  for (int test = 1; test <= t; test++) {
    solve(test);
  }
  return 0;
}
