#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string p, k;
    cin >> p;
    int i = -1, l, r, ans = 1, u[256] = {};
    for (char c : p) {
      l = i - 1;
      r = i + 1;
      if (i == -1)
        k += c, i = 0;
      else if (l >= 0 and k[l] == c)
        i = l;
      else if (r < k.size() and k[r] == c)
        i = r;
      else if (i == 0 and !u[c])
        k = c + k;
      else if (i == k.size() - 1 and !u[c])
        k = k + c, ++i;
      else
        ans = 0;
      u[c] = 1;
    }
    for (char c = 'a'; c <= 'z'; ++c)
      if (!u[c]) k += c;
    if (ans)
      cout << "YES\n" << k << "\n";
    else
      cout << "NO\n";
  }
}
