#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const int N = 210;
string str;
int exgcd1(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd1(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd2(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd2(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd3(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd3(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd4(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd4(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd5(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd5(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd6(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd6(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd7(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd7(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd8(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd8(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd9(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd9(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd10(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd10(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd11(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd1(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd12(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd2(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd13(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd3(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd14(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd4(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd15(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd5(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd16(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd6(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd17(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd7(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd18(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd8(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd19(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd9(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
int exgcd20(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd10(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - y * (a / b);
  return d;
}
inline void solve() {
  cin >> str;
  string res = "";
  int pos = 0, mp[200] = {0};
  for (int i = 0; i < str.size(); i++) {
    if (!res.size()) {
      res += str[i];
      pos = 0;
      continue;
    }
    if (res[pos] == str[i]) continue;
    if (res.size() == 1) {
      res += str[i];
      pos = 1;
      continue;
    }
    if (pos > 0 && pos < res.size() - 1) {
      if (res[pos - 1] != str[i] && res[pos + 1] != str[i]) {
        puts("NO");
        return;
      }
      if (res[pos - 1] == str[i])
        pos--;
      else
        pos++;
      continue;
    }
    if (pos == 0) {
      if (res[pos + 1] == str[i])
        pos++;
      else
        res = str[i] + res;
    } else {
      if (res[pos - 1] == str[i])
        pos--;
      else
        res += str[i], pos++;
    }
  }
  for (int i = 0; i < res.size(); i++) {
    mp[res[i]]++;
    if (mp[res[i]] > 1) {
      puts("NO");
      return;
    }
  }
  puts("YES");
  cout << res;
  for (char i = 'a'; i <= 'z'; i++)
    if (!mp[i]) printf("%c", i);
  puts("");
}
signed main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
