#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, temp, curr;
  char a;
  cin >> t;
  while (t--) {
    string s, ans = "";
    cin >> s;
    set<long long int> l[26];
    set<long long int>::iterator it;
    for (long long int i = 1; i < s.size(); i++) {
      l[s[i - 1] - 97].insert(s[i] - 97);
      l[s[i] - 97].insert(s[i - 1] - 97);
    }
    temp = 0;
    queue<long long int> dfs;
    for (long long int i = 0; i < 26; i++) {
      if (l[i].size() > 2) {
        cout << "NO"
             << "\n";
        temp = 1;
        break;
      }
    }
    if (temp) continue;
    long long int visited[26] = {0};
    for (long long int j = 0; j < 26; j++) {
      if (visited[j] == 0 && l[j].size() <= 1) dfs.push(j);
      while (!dfs.empty()) {
        curr = dfs.front();
        dfs.pop();
        if (visited[curr] == 1) continue;
        a = 97 + curr;
        ans = ans + a;
        for (it = l[curr].begin(); it != l[curr].end(); it++) {
          if (visited[*it] == 0) dfs.push(*it);
        }
        visited[curr] = 1;
      }
    }
    if (ans.size() != 26)
      cout << "NO"
           << "\n";
    else
      cout << "YES\n" << ans << "\n";
  }
  return 0;
}
