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

Solution:

//package PerfectKeyboard;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{
 public static void main (String[] args) throws IOException
    {
        StringBuilder sb = new StringBuilder();
        Scanner scan=new Scanner(System.in);
        int t=scan.nextInt();
        while(t--!=0)
        {
            String s = scan.next();
            int n=s.length();
            if(n==1)
            {
                sb.append("YES\n");
                for(int i=0;i<26;i++)
                {
                    sb.append((char)('a'+i));
                }
                sb.append("\n");
                continue;
            }
            HashMap<Character,HashSet<Character>> hm = new HashMap<>();
            boolean flag=true;
            for(int i=0;i<n;i++)
            {
                char temp = s.charAt(i);
                hm.putIfAbsent(temp, new HashSet<Character>());
                if(i>0){
                flag=add(hm.get(temp),s.charAt(i-1));
                hm.putIfAbsent(s.charAt(i-1), new HashSet<Character>());
                flag=add(hm.get(s.charAt(i-1)),temp);
                }
                if(i<n-1)
                {
                    flag=add(hm.get(temp),s.charAt(i+1));
                hm.putIfAbsent(s.charAt(i+1), new HashSet<Character>());
                flag=add(hm.get(s.charAt(i+1)),temp);
                }
                if(flag==false)
                    break;
            }
            if(!flag)
            {
                sb.append("NO\n");
                continue;
            }
            StringBuilder demo = new StringBuilder();
            char first=Character.MAX_VALUE;
            char last=Character.MAX_VALUE;
            Set<Character> key = hm.keySet();
//            System.out.println(hm);
            for(char f:key)
            {
                if(hm.get(f).size()==1 && first==Character.MAX_VALUE)
                {
                    first=f;
                }
                else if(hm.get(f).size()==1 && last==Character.MAX_VALUE)
                {
                    last=f;
                }
                else if(hm.get(f).size()==1)
                {
                    flag=false;
                }
                if(flag==false)
                {
                    break;
                }
            }
//            System.out.println(first+" jjjj "+flag+" "+last);
            if(!flag || first==Character.MAX_VALUE || last==Character.MAX_VALUE)
            {
                sb.append("NO\n");
                continue;
            }
            demo.append(first);
            char curr=first;
            int i=0;
            while(key.size()>0 && curr!=last)
            {
//                System.out.println(curr+" kkkk");
                for(char P:hm.get(curr))
                {
                    if(curr!=first)
                    {
                        if(P!=demo.charAt(i-1))
                        {
                            demo.append(P);
                            key.remove(curr);
                            
                        }
                    }
                    else
                    {
                        demo.append(P);
                        key.remove(curr);
                    }
                }
                i++;
                curr=demo.charAt(i);
            }
            key = new HashSet<Character>();
            for(i=0;i<demo.length();i++)
            {
                key.add(demo.charAt(i));
            }
            for(i=0;i<26;i++)
            {
                char k=(char)('a'+i);
                if(!key.contains(k))
                {
                    demo.append(k);
                }
            }
            sb.append("YES\n");
            sb.append(demo+"\n");
        }
        System.out.println(sb);
    }
 static boolean add(HashSet<Character> hs,char value)
 {
     if(hs.contains(value))
         {
             return true;
         }
     if(hs.size()<2)
     {
         hs.add(value);
         return true;
     }
     else
     {
             return false;
     }
 }
}