#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  vector<bool> used(26);
  used[s[0] - 'a'] = true;
  string t(1, s[0]);
  int pos = 0;
  for (int i = 1; i < int((s).size()); i++) {
    if (used[s[i] - 'a']) {
      if (pos > 0 && t[pos - 1] == s[i]) {
        pos--;
      } else if (pos + 1 < int((t).size()) && t[pos + 1] == s[i]) {
        pos++;
      } else {
        cout << "NO" << endl;
        return;
      }
    } else {
      if (pos == 0) {
        t = s[i] + t;
      } else if (pos == int((t).size()) - 1) {
        t += s[i];
        pos++;
      } else {
        cout << "NO" << endl;
        return;
      }
    }
    used[s[i] - 'a'] = true;
  }
  for (int i = 0; i < int(26); ++i)
    if (!used[i]) t += char(i + 'a');
  cout << "YES" << endl << t << endl;
}
int main() {
  int tc;
  cin >> tc;
  for (int i = 0; i < int(tc); ++i) solve();
}
