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.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int t=input.nextInt();
        while(t-->0)
        {
            String s=input.next();
            HashSet<Character> adj[]=new HashSet[27];
            for(int i=1;i<=26;i++)
            {
                adj[i]=new HashSet<>();
            }
            for(int i=0;i<s.length();i++)
            {
                char ch=s.charAt(i);
                if(i-1>=0)
                {
                    char ch1=s.charAt(i-1);
                    adj[(int)ch-96].add(ch1);
                    adj[(int)ch1-96].add(ch);
                }
                if(i+1<s.length())
                {
                    char ch1=s.charAt(i+1);
                    adj[(int)ch-96].add(ch1);
                    adj[(int)ch1-96].add(ch);
                }
            }
            ArrayList<Character> list=new ArrayList<>();
            int flag=0;
            Queue<Character> q=new LinkedList<>();
            int visit[]=new int[27];
            q.add(s.charAt(0));
            while (!q.isEmpty())
            {
                char ch=q.poll();
                visit[(int)ch-96]=1;
                int index=list.indexOf(ch);
                if(index==-1)
                {
                    list.add(ch);
                }
                if(adj[(int)ch-96].size()>2)
                {
                    flag=1;
                    break;
                }
                else if(adj[(int)ch-96].size()==2)
                {
                    Iterator it=adj[(int)ch-96].iterator();
                    ArrayList<Character> l=new ArrayList<>();
                    while (it.hasNext())
                    {
                        l.add((char)it.next());
                    }
                    if(index==-1)
                    {
                        list.add(l.get(0));
                        list.add(0,l.get(1));
                    }
                    else if(index==0)
                    {
                        char c=list.get(1);
                        if(c==l.get(0))
                        {
                            list.add(0,l.get(1));
                        }
                        else if(c==l.get(1))
                        {
                            list.add(0,l.get(0));
                        }
                        else
                        {
                            flag=1;
                            break;
                        }
                    }
                    else if(index==list.size()-1)
                    {
                        char c=list.get(index-1);
                        if(c==l.get(0))
                        {
                            list.add(l.get(1));
                        }
                        else if(c==l.get(1))
                        {
                            list.add(l.get(0));
                        }
                        else
                        {
                            flag=1;
                            break;
                        }
                    }
                    else
                    {
                        if(!((list.get(index-1)==l.get(0) && list.get(index+1)==l.get(1)) || (list.get(index+1)==l.get(0) && list.get(index-1)==l.get(1))))
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(visit[(int)l.get(0)-96]==0)
                    {
                        q.add(l.get(0));
                    }
                    if(visit[(int)l.get(1)-96]==0)
                    {
                        q.add(l.get(1));
                    }
                }
                else if(adj[(int)ch-96].size()==1)
                {
                    Iterator it=adj[(int)ch-96].iterator();
                    ArrayList<Character> l=new ArrayList<>();
                    while (it.hasNext())
                    {
                        l.add((char)it.next());
                    }
                    if(index==-1)
                    {
                        list.add(l.get(0));
                    }
                    else if(index==0)
                    {
                        char c=list.get(1);
                        if(c!=l.get(0))
                        {
                            list.add(0,l.get(0));
                        }
                    }
                    else if(index==list.size()-1)
                    {
                        char c=list.get(index-1);
                        if(c!=l.get(0))
                        {
                            list.add(l.get(0));
                        }
                    }
                    else
                    {
                        if(l.get(0)!=list.get(index-1) && l.get(0)!=list.get(index+1))
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(visit[(int)l.get(0)-96]==0)
                    {
                        q.add(l.get(0));
                    }
                }
            }
            if(flag==1)
            {
                out.println("NO");
            }
            else
            {
                HashSet<Character> set=new HashSet<>();
                for(int i=0;i<list.size();i++)
                {
                    if(set.contains(list.get(i)))
                    {
                        flag=1;
                        break;
                    }
                    else
                    {
                        set.add(list.get(i));
                    }
                }
                if(flag==1)
                {
                    out.println("NO");
                }
                else
                {
                    out.println("YES");
                    for(int i=97;i<=97+25;i++)
                    {
                        if(!list.contains((char)i))
                        {
                            list.add((char)i);
                        }
                    }
                    for(int i=0;i<list.size();i++)
                    {
                        out.print(list.get(i));
                    }
                    out.println();
                }
            }
        }
        out.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}