#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
  if (y == 0) return x;
  return GCD(y, x % y);
}
long long LCM(long long x, long long y) { return (x * y) / GCD(x, y); }
long long MPOW(long long a, long long b, long long m = LLONG_MAX) {
  if (b == 0) return 1;
  long long x = MPOW(a, b / 2, m);
  x = (x * x) % m;
  if (b % 2 == 1) x = (x * a) % m;
  return x;
}
long long MINV(long long a, long long m) { return MPOW(a, m - 2, m); }
inline long long max3(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
inline long long min3(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
inline bool sortbythis(pair<long long, long long> a,
                       pair<long long, long long> b) {
  return (((a.first == b.first) && (a.second < b.second)) ||
          (a.first < b.first));
}
inline bool sortbythat(pair<long long, long long> a,
                       pair<long long, long long> b) {
  return (((a.second == b.second) && (a.first < b.first)) ||
          (a.second < b.second));
}
class pnc {
  long long FACT_MAX, MODU;
  vector<long long> fact;

 public:
  pnc(long long n, long long m) {
    FACT_MAX = n;
    fact.resize(FACT_MAX);
    MODU = m;
    MFACT_INIT(MODU);
  }
  void MFACT_INIT(long long m) {
    fact[0] = 1;
    for (long long i = 1; i < FACT_MAX; ++i) fact[i] = (i * fact[i - 1]) % MODU;
  }
  long long MFACT(long long n) { return fact[n]; }
  long long PERM(long long n, long long r) {
    return (fact[n] * ::MINV(fact[n - r], MODU)) % MODU;
  }
  long long COMB(long long n, long long r) {
    return (PERM(n, r) * ::MINV(fact[r], MODU)) % MODU;
  }
};
void dfs(vector<vector<long long> > &graph, long long pos, vector<bool> &visit,
         string &thestring) {
  visit[pos] = true;
  thestring.push_back('a' + pos);
  for (auto x : graph[pos])
    if (!visit[x]) dfs(graph, x, visit, thestring);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long TEST = 1;
  cin >> TEST;
  while (TEST--) {
    string s;
    cin >> s;
    if (s.size() == 1) {
      cout << "YES\n";
      cout << s[0];
      for (long long i = 0; i < 26; ++i)
        if ('a' + i != s[0]) cout << (char)(i + 'a');
      cout << '\n';
      continue;
    }
    vector<vector<long long> > graph(26);
    for (long long i = 0; i < s.size() - 1; ++i) {
      bool shouldi = true;
      for (auto x : graph[s[i] - 'a'])
        shouldi &= (x != (long long)(s[i + 1] - 'a'));
      if (shouldi) {
        graph[s[i] - 'a'].push_back(s[i + 1] - 'a');
        graph[s[i + 1] - 'a'].push_back(s[i] - 'a');
      }
    }
    bool ans = true;
    for (long long i = 0; i < 26; ++i) {
      if (graph[i].size() > 2) {
        ans = false;
        break;
      }
    }
    string thestring;
    if (ans) {
      vector<bool> visit(26, false);
      bool istwo = false;
      bool isone = false;
      for (long long i = 0; i < 26; ++i) {
        if (!visit[i]) {
          if (graph[i].size() == 0) {
            visit[i] = true;
            thestring.push_back('a' + i);
          } else if (graph[i].size() == 2)
            continue;
          else {
            isone = true;
            if (istwo) {
              ans = false;
              break;
            } else {
              istwo = true;
              dfs(graph, i, visit, thestring);
            }
          }
        }
      }
      ans &= isone;
    }
    if (ans)
      cout << "YES\n" << thestring << '\n';
    else
      cout << "NO\n";
  }
  return 0;
}
