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:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Queue;
import java.util.LinkedList;
import java.util.*;

public class p_key{

    public static String f(char c){
        return Character.toString(c);
    }
    
    public static void main(String[] args) throws IOException{
        
        cf_Re.init(System.in);
        int T=cf_Re.nextInt();
        
        for(int t=0;t<T;t++){
            
            String s=cf_Re.next();
            
            if(s.length()==1){
                System.out.println("YES");
                System.out.println("abcdefghijklmnopqrstuvwxyz");
            }
            else{
                cf_g g=new cf_g(26);
            
                int[] arr=new int[26];
                
                int[][] edge_check=new int[26][26];
                
                for(int x=0;x<s.length()-1;x++){
                    char ch=s.charAt(x);
                    char ch2=s.charAt(x+1);
                    int as=ch;
                    int as2=ch2;
                    as-=97;
                    as2-=97;
                    
                    arr[as]=1;
                    arr[as2]=1;

                    if(edge_check[as][as2]==0) {
                    	g.add_edge(as,as2);
                        edge_check[as][as2]=1;
                        edge_check[as2][as]=1;
                    }
                    
                }
                
                int ctr=0;
                
                for(int r=0;r<26;r++) {
                	ctr+=arr[r];
                }
                
                int check=g.bfs();
                
                if(check==-1){
                	System.out.println("NO");
                }
                else{
                    System.out.println("YES");
                    
                    int[] all_alpha=new int[26];
                    
                    String ans="";
                    
                    ans=ans+f(s.charAt(0));
                    
                    char tmp=s.charAt(0);
                    int tas=tmp;
                    tas-=97;
                    
                    all_alpha[tas]=1;
                    
                    char last=s.charAt(0);
                    
                    for(int x=1;x<s.length();x++){
                        char ch=s.charAt(x);
                        int as=ch;
                        as-=97;
                        
                        if(all_alpha[as]==0) {
                        
	                        if(ans.charAt(0)==last){
	                            ans=f(s.charAt(x))+ans;
	                        }
	                        else{
	                            ans=ans+f(s.charAt(x));
	                        }
	                        all_alpha[as]=1;
                        }
                        
                        last=s.charAt(x);
                    }
                    
//                    for(int w=0;w<ans.length();w++) {
//                    	char c=ans.charAt(w);
//                    	int ascii=c;
//                    	ascii-=97;
//                    	all_alpha[ascii]=1;
//                    }
//                    
                    String ref="abcdefghijklmnopqrstuvwxyz";
                    
                    for(int e=0;e<26;e++) {
                    	if(all_alpha[e]==0) {
                    		ans=ans+ref.charAt(e);
                    	}
                    }
                    
                    System.out.println(ans);
                }
            }
            
        }
        
    }

}

class cf_g{
    int n;
    ArrayList<ArrayList<Integer>> adj;
    
    cf_g(int V){
        n=V;
        adj=new ArrayList<ArrayList<Integer>>();
        
        for(int h=0;h<n;h++){
            adj.add(new ArrayList<Integer>());
        }
    }
    
    void add_edge(int a,int b){
        adj.get(a).add(b);
        adj.get(b).add(a);
    }
    
    int bfs(){
        
    	int[] visit=new int[26];
    	int[] parent=new int[26];
    	
        for(int p=0;p<26;p++) {
        	
        	if(adj.get(p).size()>2) {
        		return -1;
        	}
            
        	if(visit[p]==0) {
        		Queue<Integer> q=new LinkedList<Integer>();
                visit[p]=1;
                parent[p]=p;
                // add source to q
                q.add(p);
                
                while(!q.isEmpty()){
                    int u=q.poll();
                    
                    for(int x=0;x<adj.get(u).size();x++){
                        int v=adj.get(u).get(x);
                        if(visit[v]==0){
                        	visit[v]=1;
                        	parent[v]=u;
                            q.add(v);
                        }
                        else if(parent[u]!=v){
                        	return -1;
                        }               
                        
                    }
                }
        	}
        
        }
        	
        return 1;
    }
}


/** Class for buffered reading int and double values */
class cf_Re {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}