#include <bits/stdc++.h>
using namespace std;
const int N = 26;
char m[N][2];
bool push(int u, int v) {
  for (int i = 0; i < 2; i++)
    if (m[u][i] == v)
      return true;
    else if (m[u][i] == -1) {
      m[u][i] = v;
      return true;
    }
  return false;
}
bool vis[N];
char ans[N];
int cnt;
bool dfs(int x) {
  int pre = x, now = m[x][0], next;
  ans[cnt++] = x;
  ans[cnt++] = now;
  vis[pre] = vis[now] = true;
  while (m[now][1] != -1) {
    if (m[now][0] == pre)
      next = m[now][1];
    else
      next = m[now][0];
    if (vis[next]) return false;
    vis[next] = true;
    pre = now, now = next;
    ans[cnt++] = now;
  }
  return true;
}
int main() {
  int t;
  cin >> t;
  string s;
  while (t--) {
    cin >> s;
    int l = s.length();
    if (l == 1) {
      cout << "YES" << endl;
      for (int i = 0; i < N; i++) cout << (char)(i + 'a');
      cout << endl;
      continue;
    }
    memset(m, -1, sizeof m);
    bool f = true;
    for (int i = 1; i < l; i++)
      if (!push(s[i - 1] - 'a', s[i] - 'a') ||
          !push(s[i] - 'a', s[i - 1] - 'a')) {
        f = false;
        break;
      }
    if (!f) {
      cout << "NO" << endl;
      continue;
    }
    cnt = 0;
    f = false;
    memset(vis, false, sizeof vis);
    for (int i = 0; i < N; i++)
      if (m[i][0] == -1)
        ans[cnt++] = i;
      else if (!vis[i] && m[i][1] == -1) {
        f = true;
        if (!dfs(i)) {
          f = false;
          break;
        }
      }
    if (!f) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      for (int i = 0; i < 26; i++) cout << (char)(ans[i] + 'a');
      cout << endl;
    }
  }
}
