#include <bits/stdc++.h>
using namespace std;
ifstream f("text.in");
int t, coada[26 * 2 + 5], p, u, n, ind, frecventa[26 + 5], imposibil;
string sir;
int main() {
  cin >> t;
  while (t--) {
    cin >> sir;
    n = sir.size();
    p = u = 26;
    coada[p] = sir[0] - 'a' + 1;
    frecventa[sir[0] - 'a' + 1] = 1;
    ind = p;
    imposibil = 0;
    for (int i = 1; i < n && !imposibil; i++) {
      if (ind == u) {
        if (ind - 1 < p || coada[ind - 1] != sir[i] - 'a' + 1) {
          coada[++u] = sir[i] - 'a' + 1;
          if (frecventa[sir[i] - 'a' + 1]) {
            imposibil = 1;
          }
          frecventa[sir[i] - 'a' + 1]++;
          ind = u;
        } else {
          ind = u - 1;
        }
      } else if (ind == p) {
        if (ind + 1 > u || coada[ind + 1] != sir[i] - 'a' + 1) {
          coada[--p] = sir[i] - 'a' + 1;
          if (frecventa[sir[i] - 'a' + 1]) {
            imposibil = 1;
          }
          frecventa[sir[i] - 'a' + 1]++;
          ind = p;
        } else {
          ind = p + 1;
        }
      } else {
        if (coada[ind + 1] == sir[i] - 'a' + 1) {
          ind++;
        } else if (coada[ind - 1] == sir[i] - 'a' + 1) {
          ind--;
        } else {
          imposibil = 1;
        }
      }
    }
    if (imposibil) {
      cout << "NO" << '\n';
    } else {
      cout << "YES" << '\n';
      for (int i = p; i <= u; i++) {
        cout << (char)(coada[i] + 'a' - 1);
      }
      for (int i = 1; i <= 26; i++) {
        if (!frecventa[i]) {
          cout << (char)(i + 'a' - 1);
        }
      }
      cout << '\n';
    }
    for (int i = 1; i <= 26; i++) {
      frecventa[i] = 0;
    }
    for (int i = 0; i <= 2 * 26 + 4; i++) {
      coada[i] = 0;
    }
  }
}
