#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.length();
    int a[100], ptr = 50, left = 50, right = 50;
    vector<int> b(26);
    a[ptr] = (int)(s[0] - 'a');
    b[(int)(s[0] - 'a')]++;
    string res = "YES";
    for (int i = 1; i < n; i++) {
      if (ptr > left && a[ptr - 1] == (int)(s[i] - 'a'))
        ptr--;
      else if (ptr < right && a[ptr + 1] == (int)(s[i] - 'a'))
        ptr++;
      else if (ptr > left && ptr < right) {
        res = "NO";
      } else if (ptr > left) {
        a[ptr + 1] = (int)(s[i] - 'a');
        b[(int)(s[i] - 'a')]++;
        ptr++;
        right++;
      } else {
        a[ptr - 1] = (int)(s[i] - 'a');
        b[(int)(s[i] - 'a')]++;
        ptr--;
        left--;
      }
    }
    for (int i = 0; i < 26; i++) {
      if (b[i] > 1) {
        res = "NO";
        break;
      }
      if (b[i] == 0) {
        b[i]++;
        a[right + 1] = i;
        right++;
      }
    }
    cout << res << '\n';
    if (res == "YES") {
      for (int i = left; i <= right; i++) cout << (char)(a[i] + 'a');
      cout << '\n';
    }
  }
  return 0;
}
