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:
import sys
from collections import defaultdict
def can(dic,start):
    vis=defaultdict(int)
    q=[start]
    vis[start]=1
    ans=start
    #print(ans)
    while q and len(ans)<=len(dic):
        #print(ans)
        let=q.pop(0)
        #print(let,'let')
        if len(dic[let])>2:
            return False
        if len(dic[let])==1:
            l=[]
            for i in dic[let]:
                l.append(i)
            if vis[l[0]]==1:
                if ans[0]==let:
                    if ans[1]!=l[0]:
                        return False
                if ans[-1]==let:
                    if ans[-2]!=l[0]:
                        return False
            else:
                vis[l[0]]=1
                if ans[0]==let:
                    ans=l[0]+ans
                    q.append(l[0])
                elif ans[-1]==let:
                    ans=ans+l[0]
                    q.append(l[0])
                else:
                    return False
        if len(dic[let])==2:
            l=[]
            for i in dic[let]:
                l.append(i)
            if vis[l[0]]==0 and vis[l[1]]==0:
                if len(ans)==1:
                    ans=l[0]+ans+l[1]
                    q.append(l[0])
                    q.append(l[1])
                    vis[l[0]],vis[l[1]]=1,1
                else:
                    return False
            elif vis[l[1]]==1 and vis[l[0]]==1:
                return False
            elif vis[l[1]]==0 and vis[l[0]]==1:
                if ans[0]==let:
                    if ans[1]==l[0]:
                        ans=l[1]+ans
                    else:
                        return False
                if ans[-1]==let:
                    if ans[-2]==l[0]:
                        ans=ans+l[1]
                    else:
                        return False
                q.append(l[1])
                vis[l[1]]=1
            else:
                if ans[0]==let:
                    if ans[1]==l[1]:
                        ans=l[0]+ans
                    else:
                        return False
                if ans[-1]==let:
                    if ans[-2]==l[0]:
                        ans=ans+l[0]
                    else:
                        return False
                q.append(l[0])
                vis[l[0]]=1
    return ans
t=int(sys.stdin.readline())

for _ in range(t):
    s=sys.stdin.readline()[:-1]
    l='abcdefghijklmnopqrstuvwxyz'
    if len(s)==1:
        print('YES')
        print(l)
    else:
        dic=defaultdict(list)
        vis=defaultdict(int)
        ans=''
        if s[1] not in dic[s[0]]:
            dic[s[0]].append(s[1])
        if s[0] not in dic[s[1]]:
            dic[s[1]].append(s[0])
        start=s[0]
        for i in range(1,len(s)-1):
            if s[i-1] not in dic[s[i]]:
                dic[s[i]].append(s[i-1])
            if s[i+1] not in dic[s[i]]:
                dic[s[i]].append(s[i+1])
            if s[i] not in dic[s[i+1]]:
                dic[s[i+1]].append(s[i])
            if s[i] not in dic[s[i-1]]:
                dic[s[i-1]].append(s[i])
        if s[len(s)-2] not in dic[s[len(s)-1]]:
            dic[s[len(s)-1]].append(s[len(s)-2])
        if s[len(s)-1] not in dic[s[len(s)-2]]:
            dic[s[len(s)-2]].append(s[len(s)-1])
        #print(dic,'dic')
        ans=can(dic,s[0])
        if ans:
            print('YES')
            for i in l:
                if i not in ans:
                    ans=i+ans
            print(ans)
        else:
            print('NO')