#include <bits/stdc++.h>
using namespace std;
string ans = "";
set<int> s[26];
map<int, bool> vis;
void solve(char a) {
  ans += a;
  vis[a - 'a'] = true;
  for (auto it : s[a - 'a']) {
    if (!vis[it - 'a']) {
      solve(it);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    int n = str.length();
    string alp = "abcdefghijklmnopqrstuvwxyz";
    if (n == 1) {
      cout << "YES" << endl;
      cout << alp << endl;
      continue;
    }
    for (int i = 0; i < 26; i++) s[i].clear();
    vis.clear();
    ans = "";
    for (long long int i = 1; i < n - 1; i++) {
      s[str[i] - 'a'].insert(str[i - 1]);
      s[str[i] - 'a'].insert(str[i + 1]);
    }
    s[str[0] - 'a'].insert(str[1]);
    s[str[n - 1] - 'a'].insert(str[n - 2]);
    int flag = 0, cnt = 0;
    char st;
    for (long long int i = 0; i < 26; i++) {
      if (s[i].size() > 2) {
        flag = 1;
      } else if (s[i].size() == 1) {
        cnt++;
        st = alp[i];
      }
    }
    if (flag or cnt < 2) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
    solve(st);
    for (int i = 0; i < 26; i++) {
      if (!vis[alp[i] - 'a']) ans += alp[i];
    }
    cout << ans << endl;
  }
  return 0;
}
