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

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        int t = ni();
        while(t-- > 0) {
            HashSet<Integer>[] graph = new HashSet[26];
            for(int i=0; i<26; i++)
                graph[i] = new HashSet<>();
            String s = nt();
            for(int i=1; i<s.length(); i++) {
                int a = s.charAt(i - 1) - 'a';
                int b = s.charAt(i) - 'a';
                graph[a].add(b);
                graph[b].add(a);
            }
            
            boolean invalid = cycleFound(graph);
            for(int i=0; i<26; i++) {
                if(graph[i].size() > 2)
                    invalid = true;
            }
            
            if(invalid) {
                pl("NO");
            } else {
                pl("YES");
                boolean[] visited = new boolean[26];
                builder = new StringBuilder("");
                for(int i=0; i<graph.length; i++) {
                    if(graph[i].size() == 1) {
                        findPath(i, graph, visited);
                        break;
                    }
                }
                for(int i=0; i<visited.length; i++) {
                    if(!visited[i])
                        builder.append((char)(i + 'a'));
                }
                pl(builder);
            }
        }
    }
    
    StringBuilder builder = new StringBuilder("");
    void findPath(int node, HashSet<Integer>[] graph, boolean[] visited) {
        if(visited[node]) return;
        visited[node] = true;
        builder.append((char)(node + 'a'));
        for(int adj : graph[node])
            findPath(adj, graph, visited);
    }
    
    boolean cycleFound(HashSet<Integer>[] graph) {
        DisjointSet set = new DisjointSet(26);
        HashSet<Point> added = new HashSet<>();
        for(int i=0; i<26; i++) {
            int a = i;
            for(int adj : graph[i]) {
                int b = adj;
                if(added.contains(new Point(a, b))) {
                    //do nothing
                } else {
                    boolean ok = set.union(a, b);
                    if(ok) return true;
                    added.add(new Point(a, b));
                    added.add(new Point(b, a));
                }
            }
        }
        return false;
    }
    
    class DisjointSet {
        Node[] djset;
        public DisjointSet(int n) {
            djset = new Node[n];
            for(int i=0; i<n; i++)
                djset[i] = new Node();
        }
        
        int root(int node) {
            if(djset[node].parent == -1)
                return node;
            else
                return root(djset[node].parent);
        }
        
        boolean union(int a, int b) {
            int par_a = root(a);
            int par_b = root(b);
            if(par_a == par_b) return true; //cycle found
            if(djset[par_a].members > djset[par_b].members) {
                djset[par_b].parent = par_a;
            } else {
                djset[par_a].parent = par_b;
            }
            return false; //not a cycle
        }
        
        class Node {
            int members, parent;
            public Node() {
                this.parent = -1;
                this.members = 1;
            }
        }
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}