Problem: Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all 26 lowercase Latin letters will be arranged in some order.

Polycarp uses the same password s on all websites where he is registered (it is bad, but he doesn't care). He wants to assemble a keyboard that will allow to type this password very easily. He doesn't like to move his fingers while typing the password, so, for each pair of adjacent characters in s, they should be adjacent on the keyboard. For example, if the password is abacaba, then the layout cabdefghi... is perfect, since characters a and c are adjacent on the keyboard, and a and b are adjacent on the keyboard. It is guaranteed that there are no two adjacent equal characters in s, so, for example, the password cannot be password (two characters s are adjacent).

Can you help Polycarp with choosing the perfect layout of the keyboard, if it is possible?

Input

The first line contains one integer T (1 ≤ T ≤ 1000) — the number of test cases.

Then T lines follow, each containing one string s (1 ≤ |s| ≤ 200) representing the test case. s consists of lowercase Latin letters only. There are no two adjacent equal characters in s.

Output

For each test case, do the following:

  * if it is impossible to assemble a perfect keyboard, print NO (in upper case, it matters in this problem); 
  * otherwise, print YES (in upper case), and then a string consisting of 26 lowercase Latin letters — the perfect layout. Each Latin letter should appear in this string exactly once. If there are multiple answers, print any of them. 

Example

Input


5
ababa
codedoca
abcda
zxzytyz
abcdefghijklmnopqrstuvwxyza


Output


YES
bacdefghijklmnopqrstuvwxyz
YES
edocabfghijklmnpqrstuvwxyz
NO
YES
xzytabcdefghijklmnopqrsuvw
NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long temp;
long long ans[26][3 * 26];
long long p, q, si;
vector<long long> buffer(26);
vector<long long> a[26];
long long settle(long long ap, long long first) {
  if (first == 1) {
    long long flag = 0;
    for (long long i = 0; i < a[ap].size(); i++) {
      if (buffer[a[ap][i]] == 0) {
        flag = 1;
        ans[p][q] = a[ap][i];
        buffer[a[ap][i]] = q;
        q++;
        settle(a[ap][i], 1);
      } else {
        if (buffer[a[ap][i]] != q - 2) return 1;
      }
    }
    return 0;
  } else {
    long long flag = 0;
    for (long long i = 0; i < a[ap].size(); i++) {
      if (buffer[a[ap][i]] == 0) {
        flag = 1;
        ans[p][si] = a[ap][i];
        buffer[a[ap][i]] = si;
        si--;
        settle(a[ap][i], 0);
      } else {
        if (buffer[a[ap][i]] != si + 2) return 1;
      }
    }
    return 0;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    s.push_back('/');
    s = "/" + s;
    long long arr[27][27];
    for (long long i = 0; i < 27; i++) {
      for (long long j = 0; j < 27; j++) arr[i][j] = 0;
    }
    for (long long i = 1; i < s.size() - 1; i++) {
      if ((s[i + 1]) >= 'a' && (s[i + 1]) <= 'z') {
        arr[s[i] - 'a'][s[i + 1] - 'a'] = 1;
      }
      if ((s[i - 1]) >= 'a' && (s[i - 1]) <= 'z') {
        arr[s[i] - 'a'][s[i - 1] - 'a'] = 1;
      }
    }
    long long flag = 1;
    for (long long i = 0; i < 26; i++) {
      a[i].clear();
    }
    for (long long i = 0; i < 26; i++) {
      temp = 0;
      for (long long j = 0; j < 26; j++) {
        if (arr[i][j] == 1) {
          a[i].push_back(j);
          temp++;
        }
      }
      if (temp > 2) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) {
      cout << "NO" << '\n';
      continue;
    }
    flag = 0;
    for (long long i = 0; i < 26; i++) {
      for (long long j = 0; j < 3 * 26; j++) {
        ans[i][j] = -1;
      }
    }
    for (long long i = 0; i < 26; i++) buffer[i] = 0;
    p = -1, q = 39, si = 38;
    for (long long i = 0; i < 26; i++) {
      if (a[i].size() == 2) {
        if (buffer[i] == 0) {
          p++;
          q = 39, si = 38;
          ans[p][q] = i;
          buffer[i] = q;
          q++;
          ans[p][q] = a[i][0];
          buffer[a[i][0]] = q;
          q++;
          flag = settle(a[i][0], 1);
          ans[p][si] = a[i][1];
          buffer[a[i][1]] = si;
          si--;
          flag = settle(a[i][1], 0);
        }
      } else if (a[i].size() == 1) {
        if (buffer[i] == 0) {
          p++;
          q = 39, si = 38;
          ans[p][q] = i;
          buffer[i] = q;
          q++;
          ans[p][q] = a[i][0];
          buffer[a[i][0]] = q;
          q++;
          flag = settle(a[i][0], 1);
        }
      }
    }
    vector<long long> fans;
    for (long long i = 0; i < 26; i++) {
      for (long long j = 0; j < 3 * 26; j++) {
        if (ans[i][j] != -1) fans.push_back(ans[i][j]);
      }
    }
    for (long long i = 0; i < 26; i++) {
      if (buffer[i] == 0) fans.push_back(i);
    }
    if (flag == 1) {
      cout << "NO" << '\n';
      continue;
    }
    cout << "YES" << '\n';
    for (long long i = 0; i < fans.size(); i++) cout << char(fans[i] + 'a');
    cout << '\n';
  }
  return 0;
}