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 clipse;


import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.io.*;
import java.math.*;
// alt+shift+r

public class cc
{
	
	static ArrayList<ArrayList<Integer>>graph;
	static long coin=0;
	static boolean visited[];
	static int color[];
	static int A[];
	static dsu dsu;
	static long cc=0;
	static String s;
	
	
	/*static boolean cycle(int src,int par)
	{
		visited[src]=true;
		
		for(int child:graph.get(src))
		{
			if(!visited[child])
			{
				if(cycle(child,src)==true)
				{
					
					//System.out.println("returning true"+child+"--->pr"+par);
					return true;
				}
			}
			else
			{
				if(child!=par)
				{
					//System.out.println("returning true"+child+"--->pr"+par);
					return true;
				}
			}
		}
		//System.out.println("returning false--->pr"+src);
		return false;
		
	}
	*/
	static void dfs(int ind)
	{
		visited[ind]=true;
		s+=(char)(ind+'a');
		for(int a:graph.get(ind))
		{
			if(!visited[a])
				dfs(a);
		}
		
		
	}
	
	
	
	
	
	
	
	 public static void main(String[] args)
	    {
		int t=i();
		
		while(t-->0)
		{
			int flag=-1;
			char c[]=s().toCharArray();
			int n=c.length;
			int A[]=new int[n];
			for(int i=0;i<n;i++)
				A[i]=(int)(c[i]-'a');
			
			graph=new ArrayList<>();
			for(int i=0;i<26;i++)
			{
				graph.add(new ArrayList<>());
			}
			
			
			if(n==1)
			{
				System.out.println("YES");
				for(int i=0;i<26;i++)
					System.out.print((char)(i+'a'));
				System.out.println();
				
				
				
			}else {
			
			
			
			
			
			
			
			for(int i=0;i<n-1;i++)
			{
				if(graph.get(A[i]).size()==0)
				{
					graph.get(A[i]).add(A[i+1]);
				}
				else if(graph.get(A[i]).size()==1)
				{
					int v1=graph.get(A[i]).get(0);
					if(A[i+1]!=v1)
						graph.get(A[i]).add(A[i+1]);
					
				}
				else if(graph.get(A[i]).size()==2)
				{

					int v1=graph.get(A[i]).get(0);

					int v2=graph.get(A[i]).get(1);
					if(A[i+1]!=v1&&A[i+1]!=v2)
					{
						
						flag=0;
						break;
					}
					
				}
				
				
				if(graph.get(A[i+1]).size()==0)
				{
					graph.get(A[i+1]).add(A[i]);
				}
				else if(graph.get(A[i+1]).size()==1)
				{
					int v1=graph.get(A[i+1]).get(0);
					if(A[i]!=v1)
						graph.get(A[i+1]).add(A[i]);
					
				}
				else if(graph.get(A[i+1]).size()==2)
				{

					int v1=graph.get(A[i+1]).get(0);

					int v2=graph.get(A[i+1]).get(1);
					if(A[i]!=v1&&A[i]!=v2)
					{
						
						flag=0;
						break;
					}
					
				}
				
				
			}
			
			if(flag==-1)
			{
				int ind=-1;
				for(int i=0;i<26;i++)
				{
					if(graph.get(i).size()==1)
					{
						ind=i;
						break;
					}
				}
				if(ind==-1)
					System.out.println("NO");
				else
				{
					System.out.println("YES");
					visited=new boolean[26];
					s="";
					dfs(ind);
					
					for(int i=0;i<26;i++)
					{
						if(!visited[i])
						{
							s+=(char)(i+'a');
						}
					}
					System.out.println(s);
					
					
				}
				
				
				
				
				
				
				
			}
			else
			{
				System.out.println("NO");
			}
			}
			
			
			
			
			
			
		}
		
	    }
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
//*******************************************************************DISJOINT SET UNION****************************************************************************************************************************************************************//	 
	
	 
	 
	 
	 
	 
	 
	 static class dsu
	 {
		 int parent[];
		 int size[];
		 dsu(int n)
		 {
			 parent=new int[n+1];
			 size=new int[n+1];
			 for(int i=0;i<=n;i++) 
			 {
				 parent[i]=-1;
			 	size[i]=1;
			 }
		 }
		 int find(int a)
		 {
			 if(parent[a]<0)
				 return a;
			 else {
				 int x=find(parent[a]);
				 parent[a]=x;
				 return x;
				 
			 }
		 }
		 void union(int a,int b)
		 {
			a=find(a);
			 b=find(b);
			 
			if(a==b)return;
			
			parent[b]=a;
		 }
		 
		 
		 
	 }
	 
	 
//*******************************************PRIME FACTORIZE *****************************************************************************************************//
	 static TreeMap<Integer,Integer> prime(long n)
	 {
		 TreeMap<Integer,Integer>h=new TreeMap<>();
		 long num=n;
		 for(int i=2;i<=Math.sqrt(num);i++)
		 {
			 if(n%i==0)
			 {
				 int nt=0;
				 while(n%i==0) {
					 n=n/i;
					 nt++;
				 }
				 h.put(i, nt);
			 }
		 }
		 if(n!=1)
			 h.put((int)n, 1);
		 return h;
		 
	 }
	 
	
	
//*************CLASS PAIR ***********************************************************************************************************************************************
	    static class pair implements Comparable<pair>
	    {
	        int x;
	        int y;

	        pair(int x, int y) {
	            this.x = x;
	            this.y = y;
	        }
	        public int compareTo(pair o) {
	        	
	        return x-o.x;
	        }
	    }
//*************CLASS PAIR *****************************************************************************************************************************************************
	
	
	

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int Int() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String String() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return String();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }

    static InputReader in = new InputReader(System.in);
    static OutputWriter out = new OutputWriter(System.out);
    static int modulus = (int) (1e9+7);

    public static int[] sort(int[] a) {
        int n = a.length;
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a)
            l.add(i);
        Collections.sort(l);
        for (int i = 0; i < l.size(); i++)
            a[i] = l.get(i);
        return a;
    }

    public static long pow(long x, long y) {
        long res = 1;
        while (y > 0) {
            if (y % 2 != 0) {
                res = (res * x) % modulus;
                y--;

            }
            x = (x * x) % modulus;
            y = y / 2;
        }
        return res;
    }
//GCD___+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    public static long gcd(long x, long y) {
        if (x == 0)
            return y;
        else
            return gcd(y % x, x);
    }
    //****************LOWEST COMMON MULTIPLE   *************************************************************************************************************************************

    public static long lcm(long x, long y) {
        return (x * (y / gcd(x, y)));
    }
//INPUT PATTERN******************************************************************************************************************************************************************
    public static int i() {
        return in.Int();
    }

    public static long l() {
        String s = in.String();
        return Long.parseLong(s);
    }

    public static String s() {
        return in.String();
    }

    public static int[] readArray(int n) {
        int A[] = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = i();
        }
        return A;
    }

    public static long[] readArray(long n) {
        long A[] = new long[(int) n];
        for (int i = 0; i < n; i++) {
            A[i] = l();
        }
        return A;
    }

}