#include <bits/stdc++.h>
using namespace std;
int T, d[26], cur;
char s[1010], ans[26];
bool ok, vis[26], G[26][26];
void dfs(int x, int fa) {
  if (vis[x])
    return;
  else
    vis[x] = 1;
  ans[cur++] = x + 'a';
  for (int y = 0; y < 26; y++)
    if (G[x][y])
      if (y != fa)
        if (vis[y])
          ok = false;
        else
          dfs(y, x);
}
int main() {
  int i, j, x, y;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", &s);
    for (i = 1; i < strlen(s); i++) {
      x = s[i - 1] - 'a';
      y = s[i] - 'a';
      if (!G[x][y]) {
        G[x][y] = 1;
        G[y][x] = 1;
        d[x]++;
        d[y]++;
      }
    }
    ok = true;
    cur = 0;
    for (i = 0; i < 26; i++)
      if (d[i] > 2)
        ok = false;
      else if (d[i] < 2)
        dfs(i, -1);
    ok = ok && (cur == 26);
    if (ok) {
      printf("YES\n%s\n", ans);
    } else
      printf("NO\n");
    for (i = 0; i < 26; i++) {
      for (j = 0; j < 26; j++) G[i][j] = 0;
      d[i] = 0;
      vis[i] = 0;
    }
  }
}
