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.util.*;
import java.io.*;
import java.math.*;
public class Main{


	static int p=1000000007;
	
	public static void main (String args[])throws IOException{
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int t=sc.nextInt();
		while(t-->0) {
			
			char arr1[]=sc.next().toCharArray();
			int arr2[]= new int[26];
			int arr[][] = new int[26][26];
			for(int i=0; i<arr1.length; i++) {
				 if( i!=arr1.length-1) {
					 arr[arr1[i]-97][arr1[i+1]-97]=1;
					 arr[arr1[i+1]-97][arr1[i]-97]=1;
				 }
				 if( i!=0){
					 arr[arr1[i]-97][arr1[i-1]-97]=1;
					 arr[arr1[i-1]-97][arr1[i]-97]=1;
				 }
			}
			int size, cnt=0;
			boolean b=true;
			for(int i=0; i<26; i++) {
				size=0;
				for(int j=0; j<26; j++) {
					if(j==i)
						continue;
					size+=arr[i][j];
				}
				if(size>2) {
					b=false;
					break;
				}
				if(size==1)
					cnt++;
				arr2[i]=size;
			}
			
			if(arr1.length==1) {
				out.println("YES");
				for(int i=0; i<26; i++)
					out.print((char)(i+97));
				out.println();
			}
			else if(cnt!=2 || !b)
				out.println("NO");
			else {
				out.println("YES");
				String str="";
				int i=0;
				for(; i<26; i++) {
					if(arr2[i]==1) {
						str+=(char)(i+97);
						arr2[i]=-1;
						break;
					}
				}
				outerloop:
				for(; ; ) {
					for(int j=0; j<26; j++) {
						if(j!=i) {
							if(arr[i][j]==1 && arr2[j]!=-1) {
								str+=(char)(j+97);
								arr2[j]=-1;
								i=j;
								continue outerloop;
							}
						}
						if(j==25) {
							arr2[i]=-1;
							break outerloop;
						}
					}
				}
				
				for(i=0; i<26; i++) {
					if(arr2[i]!=-1)
						str+=(char)(i+97);
				}
				out.println(str);
			}
			
		}
		
		out.flush();
	}	
	
	
	
	
	static void print(int[] arr) {
		for(int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static int abs(int x) {return ((x > 0) ? x : -x);}
	
	public static int max(int a, int b) {return Math.max(a, b);}
	
	public static int min(int a, int b) {return Math.min(a, b);}
	
	
	 static int gcd(int a, int b)  
	    { 
	        if (a == 0) 
	            return b; 
	        return gcd(b % a, a); 
	    } 
	
	
    static int modInverse(int a, int m) 
    { 
        int g = gcd(a, m); 
        if (g != 1) 
            return -1;
        else 
        	return power(a, m - 2, m); 
        
    } 
      
    // To compute x^y under modulo m 
    static int power(int x, int y, int m)  
    { 
        if (y == 0) 
            return 1; 
          
        int p = power(x, y / 2, m) % m; 
        p = (p * p) % m; 
      
        if (y % 2 == 0) 
            return p; 
        else
            return (x * p) % m; 
    } 
	
	
    static int[] primeGenerator(int num) {
    	int length=0, arr[]=new int[num], a=num, factor=1;
    	if(num%2==0) {
    		while(num%2==0) {
    			num/=2;
    			factor*=2;
    		}
    		arr[length++]=factor;
    	}
    	for(int i=3; i*i<=a; i++) {
    		factor=1;
    		if(num%i==0) {
        		while(num%i==0) {
        			num/=i;
        			factor*=i;
        		}
        		arr[length++]=factor;
    		}
    	}
    	if(num>1)
    		arr[length++]=num;
    	return Arrays.copyOfRange(arr, 0, length);
    }
    
    


    static boolean isPrime(int n) 
    { 
        // Corner cases 
        if (n <= 1) 
            return false; 
        if (n <= 3) 
            return true; 
  
        // This is checked so that we can skip 
        // middle five numbers in below loop 
        if (n % 2 == 0 || n % 3 == 0) 
            return false; 
  
        for (int i = 5; i * i <= n; i = i + 6) 
            if (n % i == 0 || n % (i + 2) == 0) 
                return false; 
  
        return true; 
    }




	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}
}

class Pair{
	int x;
	int y;
	Pair(int a, int b){
		x=a;
		y=b;
	}
	
	void print() {
		System.out.println(this.x+" "+this.y);
	}
}