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>
#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;
}