#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int m = 0;
    string s;
    cin >> s;
    int h[26] = {0};
    string ans = "";
    int curr = -1;
    for (int i = 0; i < s.size(); i++) {
      if (h[s[i] - 'a'] == 0) {
        if (curr == -1) {
          ans += s[i];
          curr = 0;
        } else {
          if (curr == ans.size() - 1) {
            ans += s[i];
            curr = ans.size() - 1;
          } else if (curr == 0) {
            ans = s[i] + ans;
            curr = 0;
          } else {
            m = 1;
            break;
          }
        }
        h[s[i] - 'a'] = 1;
      } else {
        if (curr == 0) {
          if (ans[curr + 1] == s[i])
            curr++;
          else {
            m = 1;
            break;
          }
        } else if (curr == ans.size() - 1) {
          if (ans[curr - 1] == s[i]) {
            curr--;
          } else {
            m = 1;
            break;
          }
        } else {
          if (ans[curr + 1] == s[i]) {
            curr++;
          } else if (ans[curr - 1] == s[i]) {
            curr--;
          } else {
            m = 1;
            break;
          }
        }
      }
    }
    if (m == 1)
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      cout << ans;
      for (int i = 0; i < 26; i++) {
        if (h[i] == 0) {
          char k = 'a' + i;
          cout << k;
        }
      }
      cout << endl;
    }
  }
}
