#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long INFLL = 4e18L;
const int MOD = 998244353;
const int N = +3;
bool valid(string& s, vector<char>& ans) {
  map<int, int> pos;
  for (int i = 0; i <= (int)ans.size() - 1; ++i) pos[ans[i]] = i;
  for (int i = 1; i <= (int)s.size() - 1; ++i) {
    int x = pos[s[i - 1]];
    int y = pos[s[i]];
    if (abs(x - y) > 1) return false;
  }
  return true;
}
void dfs(int c, set<int> adj[], set<int>& vis, vector<char>& ans) {
  ans.push_back(char('a' + c));
  vis.insert(c);
  for (int nxt : adj[c])
    if (!vis.count(nxt)) dfs(nxt, adj, vis, ans);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(16);
  int tc;
  cin >> tc;
  while (tc--) {
    string s;
    cin >> s;
    set<int> adj[26];
    for (int i = 1; i <= (int)s.size() - 1; ++i) {
      int x = s[i - 1] - 'a';
      int y = s[i] - 'a';
      adj[x].insert(y);
      adj[y].insert(x);
    }
    vector<char> ans;
    set<int> vis;
    for (int c = 0; c <= 26 - 1; ++c)
      if (!vis.count(c) && (int)adj[c].size() == 1) dfs(c, adj, vis, ans);
    for (int c = 0; c <= 26 - 1; ++c)
      if (!vis.count(c)) dfs(c, adj, vis, ans);
    if (!valid(s, ans)) {
      cout << "NO\n";
      continue;
    }
    cout << "YES\n";
    for (char c : ans) cout << c;
    cout << '\n';
  }
}
