#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; };
void __print(long x) { cerr << x; };
void __print(long long x) { cerr << x; };
void __print(unsigned x) { cerr << x; };
void __print(unsigned long x) { cerr << x; };
void __print(unsigned long long x) { cerr << x; };
void __print(float x) { cerr << x; };
void __print(double x) { cerr << x; };
void __print(long double x) { cerr << x; };
void __print(char x) { cerr << '\'' << x << '\''; };
void __print(const char *x) { cerr << '\"' << x << '\"'; };
void __print(const string &x) { cerr << '\"' << x << '\"'; };
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long fast_pow(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long x = fast_pow(a, b / 2);
  x *= x;
  if (b & 1) x *= a;
  return x;
}
class DisjointSet {
  vector<long long> parent;
  vector<long long> rank;

 public:
  DisjointSet(long long n) {
    parent.resize(n + 1, -1);
    rank.resize(n + 1, 1);
  }
  long long Find(long long x) {
    if (parent[x] == -1) {
      return x;
    }
    return parent[x] = Find(parent[x]);
  }
  void Union(long long x, long long y) {
    long long s1 = Find(x);
    long long s2 = Find(y);
    if (s1 == s2) {
      return;
    }
    if (rank[s1] > rank[s2]) {
      parent[s2] = s1;
      rank[s1] += rank[s2];
    } else {
      parent[s1] = s2;
      rank[s2] += rank[s1];
    }
  }
};
const long long nax = 27;
vector<set<long long>> adj(nax);
vector<long long> visited(nax);
string ans = "";
void dfs(long long root) {
  ans += (char)(root + 'a');
  visited[root] = 1;
  for (auto i : adj[root]) {
    if (!visited[i]) {
      dfs(i);
    }
  }
}
void solve() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long tc;
  cin >> tc;
  while (tc--) {
    ans.clear();
    adj.clear();
    adj.resize(27);
    visited.clear();
    visited.resize(27);
    string s;
    cin >> s;
    long long n = (long long)s.size();
    bool checkcycle = 0;
    DisjointSet dSet(27);
    for (long long i = 0; i < n - 1; i++) {
      long long nodea = s[i] - 'a';
      long long nodeb = s[i + 1] - 'a';
      long long prevsz = adj[nodea].size();
      adj[nodea].insert(nodeb);
      adj[nodeb].insert(nodea);
      long long newsz = adj[nodea].size();
      if (dSet.Find(nodea) != dSet.Find(nodeb)) {
        dSet.Union(nodea, nodeb);
      } else if ((newsz != prevsz)) {
        checkcycle = 1;
      }
    }
    for (long long i = 0; i < 26; i++) {
      if (adj[i].size() > 2) {
        checkcycle = 1;
        break;
      }
      if (adj[i].size() == 0) {
        ans += (char)(i + 'a');
      } else if ((adj[i].size() == 1) && !visited[i]) {
        dfs(i);
      }
    }
    if (checkcycle) {
      cout << "NO" << '\n';
      continue;
    }
    cout << "YES" << '\n';
    cout << ans << '\n';
  }
}
int32_t main() {
  solve();
  return 0;
}
