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 PYTHON3):

Solution:
from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import heapq
# input = lambda: sys.stdin.readline().rstrip()
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations


# t = int(input())
#
# for _ in range(t):
#
#     s = input()
#     posn = []
#
#     for i in range(len(s)):
#         if s[i] == '1':
#             posn.append(i)
#
#
#     ans = 0
#     for i in range(1,len(posn)):
#         ans+=posn[i]-posn[i-1] - 1
#
#     print(ans)


# t = int(input())
#
# for _ in range(t):
#
#     n,g,b = map(int,input().split())
#
#     z = ceil(n/(g+b))
#     low = g*(n//(g+b))
#     if n%(g+b)>g:
#         low+=g
#     else:
#         low+=(n%(g+b))
#
#     if low >= ceil(n/2):
#         print(n)
#     else:
#
#         z = n/2
#         ans = (g+b)*(z//(g+b))
#         flag = 0
#         if z%(g+b) !=0:
#             ans+=g
#             flag = 1
#
#
#         n-=ans
#
#         ans+=g*(n//g) + g%n + b*(((n//g))-1)
#         if flag:
#           ans+=b
#         print(ans)

def dfs(n):

    boo[n] = True

    st.append(n)


    for i in hash[n]:

        if not boo[i]:
            dfs(i)






def find_parent(u):
    if par[u]!=u:
        par[u]=find_parent(par[u])
    return par[u]

n = int(input())

for i in range(n):

    s = list(input())

    hash = defaultdict(set)
    edg = set()
    flag = 0
    for i in range(len(s)-1):
        hash[ord(s[i])-97].add(ord(s[i+1])-97)
        hash[ord(s[i+1])-97].add(ord(s[i])-97)
        a,b = max((ord(s[i])-97,ord(s[i+1])-97)),min((ord(s[i])-97,ord(s[i+1])-97))
        edg.add((a,b))
        if len(hash[ord(s[i])-97])>2 or len(hash[ord(s[i])-97])>2:
            flag = 1
            break


    par = [i for i in range(26)]

    for a,b in edg:

        z1,z2 = find_parent(a),find_parent(b)

        if z1!=z2:

          par[z1] = z2

        else:
          flag = 1
          break

    no = []
    ans = []
    ba = []

    if not flag:

        print('YES')
        boo = [False]*(26)

        for i in range(26):

            if not boo[i] and len(hash[i]) == 1:

               st = []
               dfs(i)
               ba.append(st)


            if not boo[i] and len(hash[i]) == 0:
                no.append(i)


        for i in ba:
            ans+=i
            if no!=[]:
                z = no.pop()
                ans+=[z]
        ans+=no








        for i in range(26):
            ans[i] = chr(ans[i] + 97)
        print(''.join(ans))
    else:
        print('NO')