#include <bits/stdc++.h>
using namespace std;
const int nax = 27;
int vis[nax];
set<int> adj[nax];
int f = 0;
string s;
void dfs(int node, int par) {
  vis[node] = true;
  s += char(node + 'a');
  for (auto x : adj[node]) {
    if (x != par && vis[x]) {
      f = 1;
      return;
    }
    if (!vis[x]) dfs(x, node);
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string g;
    cin >> g;
    int n = g.length();
    for (int i = 1; i < n; i++) {
      adj[g[i] - 'a'].insert(g[i - 1] - 'a');
      adj[g[i - 1] - 'a'].insert(g[i] - 'a');
    }
    for (int i = 0; i < 26; i++) {
      if (adj[i].size() >= 3) {
        cout << "NO\n";
        goto doom;
      }
    }
    for (int i = 0; i < 26; i++) {
      if (!vis[i] && (int)adj[i].size() <= 1) {
        dfs(i, -1);
      }
    }
    if (f || (int)s.length() != 26) {
      cout << "NO\n";
      goto doom;
    }
    cout << "YES\n";
    cout << s << "\n";
  doom:;
    for (int i = 0; i < 26; i++) {
      vis[i] = false;
      adj[i].clear();
    }
    f = 0;
    s = "";
  }
  return 0;
}
