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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class First {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        //int a = 1;
        int t;
        t = in.nextInt();
        //t = 1;
        while (t > 0) {
            //out.print("Case #"+(a++)+": ");
            solver.call(in,out);
            t--;
        }
        out.close();

    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            char[] arr = in.next().toCharArray();
            int n = arr.length;

            ArrayDeque<Character> arrayDeque = new ArrayDeque<>();
            Map<Character, Set<Character>> map = new HashMap<>();

            int[] a = new int[26];

            for (int i = 0; i < n; i++) {
                if(a[arr[i]-'a']!=0){
                    if(!map.get(arr[i]).contains(arr[i-1])){
                        out.println("NO");
                        return;
                    }

                    continue;
                }
                if(i==0){
                    arrayDeque.addFirst(arr[i]);
                }
                else{
                    if(i!=n-1){
                        if(arrayDeque.peekFirst()==arr[i-1] || arrayDeque.peekFirst()==arr[i+1]){
                            arrayDeque.addFirst(arr[i]);
                            if(map.getOrDefault(arr[i],null)==null){
                                map.put(arr[i], new HashSet<>());
                            }
                            map.get(arr[i]).add(arr[i-1]);

                            if(map.getOrDefault(arr[i-1],null)==null){
                                map.put(arr[i-1], new HashSet<>());
                            }
                            map.get(arr[i-1]).add(arr[i]);
                        }

                        else if(arrayDeque.peekLast()==arr[i-1] || arrayDeque.peekLast()==arr[i+1]){
                            arrayDeque.addLast(arr[i]);

                            if(map.getOrDefault(arr[i],null)==null){
                                map.put(arr[i], new HashSet<>());
                            }
                            map.get(arr[i]).add(arr[i-1]);

                            if(map.getOrDefault(arr[i-1],null)==null){
                                map.put(arr[i-1], new HashSet<>());
                            }
                            map.get(arr[i-1]).add(arr[i]);
                        }
                        else{
                            out.println("NO");
                            return;
                        }
                    }
                    else{
                        if(arrayDeque.peekFirst()==arr[i-1]){
                            arrayDeque.addFirst(arr[i]);
                        }
                        else if(arrayDeque.peekLast()==arr[i-1]){
                            arrayDeque.addLast(arr[i]);
                        }
                        else{
                            out.println("NO");
                            return;
                        }
                    }
                }
                a[arr[i]-'a']++;
            }

            for (int i = 0; i < 26; i++) {
                if(a[i]==0){
                    arrayDeque.addFirst((char)(i+97));
                }
            }

            out.println("YES");
            while(arrayDeque.size()!=0){
                out.print(arrayDeque.pollFirst());
            }
            out.println();


        }
    }

    static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int lcm(int a, int b)
    {
        return (a / gcd(a, b)) * b;
    }

    static class answer implements Comparable<answer>{
        int a;
        int b;

        public answer(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(answer o) {
            return o.a - this.a;
        }

        @Override
        public boolean equals(Object o){
            if(o instanceof answer){
                answer c = (answer)o;
                return a == c.a && b == c.b;
            }
            return false;
        }
    }

    static class answer1 implements Comparable<answer1>{
        int a, b, c;

        public answer1(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;

        }

        @Override
        public int compareTo(answer1 o) {
            if(o.c==this.c){
                return this.a - o.a;
            }
            return o.c - this.c;
        }
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static void sort(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (Long i:a) l.add(i);
        l.sort(Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static final Random random=new Random();

    static void shuffleSort(int[] a) {
        int n=a.length;
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}