#include <bits/stdc++.h>
using namespace std;
const long long N = 500;
bitset<N> mark;
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    char c[N];
    for (long long i = 0; i < 500; ++i) c[i] = 'A';
    mark.reset();
    long long w = 210, las = 0, st = 501;
    bool ne = false;
    for (long long i = 0; i < s.size(); ++i)
      if (!mark[(long long)(s[i])]) {
        mark[(long long)(s[i])] = true;
        if (c[w] != 'A' && c[w + 1] == 'A')
          w++, c[w] = s[i];
        else if (c[w] != 'A' && c[w - 1] == 'A')
          w--, c[w] = s[i];
        else if (c[w] == 'A')
          c[w] = s[i];
        else {
          ne = true;
          break;
        }
        las = max(las, w);
        st = min(st, w);
      } else {
        if (c[w + 1] == s[i])
          w++;
        else if (c[w - 1] == s[i])
          w--;
        else {
          ne = true;
          break;
        }
        las = max(las, w);
        st = min(st, w);
      }
    las++;
    for (long long i = 97; i < 123; ++i)
      if (!mark[i]) {
        c[las] = (char)(i);
        las++;
      }
    if (ne)
      cout << "NO\n";
    else {
      cout << "YES\n";
      for (long long i = st; i < las; ++i) cout << c[i];
      cout << '\n';
    }
  }
  return 0;
}
