#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int t, len, cnt, flg, ans;
string s;
map<char, char> lst, nxt;
char now;
int vis[26];
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> s;
    memset(vis, 0, sizeof(vis));
    lst.clear();
    nxt.clear();
    len = s.size();
    flg = 0;
    now = s[0];
    vis[now - 'a'] = 1;
    for (int i = 1; i < s.size(); i++) {
      if (s[i] == lst[now] || s[i] == nxt[now]) {
        now = s[i];
      } else if (nxt[now] == 0 && !vis[s[i] - 'a']) {
        nxt[now] = s[i];
        lst[s[i]] = now;
        now = s[i];
      } else if (lst[now] == 0 && !vis[s[i] - 'a']) {
        lst[now] = s[i];
        nxt[s[i]] = now;
        now = s[i];
      } else {
        flg = 1;
        break;
      }
      vis[s[i] - 'a'] = 1;
    }
    if (flg)
      cout << "NO\n";
    else {
      cout << "YES\n";
      while (lst[now] != 0) now = lst[now];
      while (now != 0) {
        cout << now;
        now = nxt[now];
      }
      for (int i = 0; i < 26; i++)
        if (!vis[i]) cout << char(i + 'a');
      cout << '\n';
    }
  }
  return 0;
}
