#include <bits/stdc++.h>
using namespace std;
int n, t;
char s[220];
bool vis[220];
set<int> edge[220];
queue<char> ans;
void dfs(int x) {
  ans.push(x);
  vis[x] = true;
  for (set<int>::iterator it = edge[x].begin(); it != edge[x].end(); it++)
    if (vis[*it] == false) dfs(*it);
}
void work() {
  for (int i = 'a'; i <= 'z'; ++i) vis[i] = false, edge[i].clear();
  while (ans.empty() == false) ans.pop();
  for (int i = 0; s[i + 1]; ++i)
    edge[s[i]].insert(s[i + 1]), edge[s[i + 1]].insert(s[i]);
  for (int i = 'a'; i <= 'z'; ++i)
    if (edge[i].size() > 2) {
      cout << "NO" << endl;
      return;
    }
  for (int i = 'a'; i <= 'z'; ++i)
    if (vis[i] == false && edge[i].size() <= 1) dfs(i);
  if (ans.size() == 26) {
    cout << "YES" << endl;
    while (ans.empty() == false) cout << ans.front(), ans.pop();
    cout << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> s;
    work();
  }
  return 0;
}
