#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int t, deg[30], mp[30][30], visit[30];
string s, ans;
void dfs(int u) {
  visit[u] = 1;
  ans += u + 'a' - 1;
  for (int v = 1; v <= 26; ++v) {
    if (visit[v]) continue;
    if (mp[u][v]) dfs(v);
  }
}
int main() {
  cin >> t;
  while (t--) {
    memset(deg, 0, sizeof(deg));
    memset(mp, 0, sizeof(mp));
    memset(visit, 0, sizeof(visit));
    cin >> s;
    if (s.size() == 1) {
      puts("YES");
      for (int i = 1; i <= 27; ++i) printf("%c", i == 27 ? '\n' : 'a' + i - 1);
      continue;
    }
    for (int i = 1; i < s.size(); ++i) {
      int u = s[i - 1] - 'a' + 1, v = s[i] - 'a' + 1;
      mp[u][v] = mp[v][u] = 1;
    }
    for (int i = 1; i <= 26; ++i)
      for (int j = 1; j <= 26; ++j) deg[i] += mp[i][j];
    int ok = 1, rt = -1;
    for (int i = 1; i <= 26; ++i) {
      if (deg[i] > 2) ok = 0;
      if (deg[i] == 1) rt = i;
    }
    if (!ok || rt == -1) {
      puts("NO");
      continue;
    }
    ans = "";
    dfs(rt);
    for (int i = 1; i <= 26; ++i)
      if (deg[i] == 0) ans += 'a' + i - 1;
    puts("YES");
    cout << ans << "\n";
  }
  return 0;
}
