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:
// Dababy Convertible
//
//                                                          `.:;i+#+     ``   `
//                                                ``,:i*+znxMWWWWWWx#nnzxxxxxxxn#+##z*i+#*;`
//                                             `#xMMWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWM+,
//                                          `.:ixMWWWWWWWWWWWWWWWWWWWWWWMMMMWWMMMWWWWWMMMMMMMMz#*:
//                                      `.;*nMWWWWWWWWWWWWWWWMMMMMMMMMxxxxxxxxxxxxxxxxxnxnxxxxxxxx+.
//                                    `;nWWWWWMMMMMMMMMMMMMMMMxxxxxxnnnnnnnnnnzzzzznnnnnnnnnnnnnnxxn+;.`
//                                  `inMWWWMMMMxxxxxxxxxxxxxxxxnnnnnnzzzzzzzzzzzzzzzzzzznnnnnnnnnnnxnxnz+:``
//                                .#MMMMMMxxnnnnnnnnnnnnnnnnnnzzzzzzzzzzzzzzzzzzzzzzzzzzzzznzznnnnnnnnnnnnz*,
//                              `#MWMMxxnnznzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzznnnnnnnnnnnnnnnn+;
//                             ,xMMxxnzzzzzzzzzzzz#####zzzzzzzzzzzzz######zzzzzzzzzzzzzzzzzzzzznnnnnnnnnnnnnxxx*`
//                           .#MMxxnnzzzzzz#################################z###zzzzzzzzznzzzzzznznnnnnnnnnnxxxn*
//                          `*MMxnnzzz##########++++++++++++++++#################zzzzzzzzzzzzzzzzznnnnnnnnnxxxxnn.
//                         `#Mxnnzzz####++++++++++++++++++++++++++++++++++########zzzzzzzzzzzzzzzzznnnnxxxxxxMMxx#
//                        `*xxnzzz#####++++++++++**************iiiii***+++++++##############zzzzznxxxMMMMWWWWWWWMxi.
//                        ,nxnnz#z####++++++++++*****iiiiiiiiiiiiiiiii****++++++###########zzznnnxnxxxMMWWWWWWWWMMx#.
//                        :nnnzzz#####++++++******iiiii;;;;;;;;;;iiiii******+++##############zz#zzznnxxMMMWWWMMMMMxx:
//                       .#nzzzz#######++++***iiiiii;;;;;;;;;;;;;iiiiiii****++++++#+#+++++++++##zznnxxMMMMMMMMMMxxxn;`
//                       ;zzz##########++++**iiii;;;;;;;;;;;;;;;iiiiiii*****++++++++++++++++###zzznnxMMWWMMMxxxxxxzi`
//                       iz#############+++**ii;;;;;;;;;;;;;;;;;iiiiii********++++++++++####zzzznznnxMMWWWMMxxxxMzi:
//                       *z#############++++*iii;;;;;;;;;;;;;;;iiii********+++++++++###zzznnxxxxxxxxMWWWWMMMxxxxn+*,
//                      .################++++*iiiiii;;;;iiiiiiiii*********+++++######zzzzznxxxxnxxxxMW@WWMMMxxxnnz#+i,```
//                      ,##################+++****iiiiiiiiiiiii************++++######zzzzznnnnnnxxxMMWWWWMMxxnnzzz####++**;,,:::.
//                      ,#####z###############++++**iiiiiiiii**************++++########zzzzzzzznnnxxxMMMMxxnnnzzzz###+#++++++*++##+`
//                      ,#####z##################z##+**iiiiii**************+++++#######z###zzzzzzznnxxxxxxxnnnnzz######+++++++++#nn
//                      .#################++#zzz#zzz#++**iii****iiiiiiii*****+++++################zzznnxxnnnnnzz##++++++++##+++#znn
//                      .############++++#nnz#zzz##++++**ii****iiiiiiiii*iii***++++++++##############zznnnnnnnn#+*ii*++#zxMxn##z++*`
//                      `+###########+++#nn+**#z###+*++**ii****iiiiiiiiiiiiiii**+++++++++++++++++++###zzzznxxMxn#*+##znxxxz###*.
//                       ;############++#xz**+znnxx#*+++**i****iiiiiiiiiiiiiiii********+++++++++++++####znnxMMMxnzzzzzzzznxnz:
//                       `+zz##zzzzz###+zx#*+znxMxz*+z#***ii***iii******iiiiiiiiiiiii***++++++++++++####znxxxxxzz#zzzzznxMMxn;
//                        ;#z##zzzzz###+#n#*+zxMMz*+##+++**iii*iii********iiiiiiiiiiiii*****+++++######znxMMxnnz##znnnnxMMMMMMi
//                        `:+zzzzzzzzz##+##++#nMxz#z+i*+#+**iiiiii*******iiiiiiiiiiiiii*****++++#######znxxxnzzz##zzz#zznxxxMxn:
//                          :#zzzzzzzzz######+#znz#+*+#z##+**iiiiiiiiiiiiiiiiii;;iiiii****++++#++++++#zznxnnz##++#znnnnnnnxxMMMz`
//                           :zzzzzzzzz###+####z#++***++###+***iiiiiiiiiiiii;i;;;iii****++#zzz#+***++#zxnnxnz####+*iii;:;;;+#ni`
//                            :zzzzzzzz###+++###zz#+*i**i;iz#****iiiiiiiiiii;;;;;iii**++#zznnz#*ii**+#nnxWWM#:,,,...,,.,;;i*ii;
//                             *zzzzzzzz##++++++++#++*+i,,:nn++***iiiiiiiii;;;;;;iii**+##znz#+*i;i**+#znxMx#*iiiiii***++###+**;`
//                             `#zzzzzzzz####++*****++++*+zMn++++***iiiiiiiii;;;;iii**+##zz#+*iiii*++#znnxnz#++*+**********+###*`
//                              izzzzzzzzzzz##++**iiiii***++++++++****iiiiiii;;;iiii*++###z#+*ii**++##znnnnz#++++++++*+++++#zzzn.
//                               +nzzznnnnxxxnz+************+++#+++****iiiiiiiiiiiii*++++##+++++++####zzzzzz###xWWWMxxxnzznnnxxx,
//                               .zzzznxxxxxxxxxz**********+++####+++******iiiii*******+++++++#######zzzzzz##zWWMxxxxxMMWWxxMMMx`
//                                ;nnnxxMMxxMMMxxz*********+++###z##++++*********++++++++++###############zz#WWMxxMMMMMMMWWMMMn:
//                                 +nxMx#++*;#nMxxz****+***+++##zzzzz##+++++++++++++++#####################zMWMMMn#+##zMMMWMMz,
//                                 ixMni*MW;.+#zxxMz***++++++###zzzzzzz####################################nWMxM+;;WW::+xMMMx,
//                                 zxx#;,zn*+nWznxMM++++++++#####zzzzzzzzzzzzz##zz#######zzzz########++++++MMxM#z*,#x.;z#xMxz.
//                                ,xMnnni:*+#nM#+xMMx+++++++#####zzzzzznnnzznnzzzzzzzzzzzzzz########++++++#WMMnzWz+iii#nzzMxz:
//                                ixMzxMz+i+*i,,inxM@z+++++######zzzzzzznnnnxnnnnnnzzzzzzzzzz########++++##WxMzzn#+*i+**i#Mxn:
//                                *xx#*#*+*i+i*+#nxMW#++++####zzzzzzzzznznnnnnnxxnnnnnnnzzzzz#########+####MxM*.::i+**,,,*xMn.
//                                iMxi.,:+*i##nMznxMW++++###zznnnxxxnnnnnnnnnnnnxxxxxxxxnnnzzzzzzzzzzzzz##zMMM#+#+#+;##+++xM*`
//                                ;MMi++n+*#i:xW+nMMWnzznMMMWWWWWWWWWMxxxxxxxxxxMMMWWWMMMMMMMMMMxxxnnnnnnnnMMM#nnn:++;#n+*xMi
//                                .xM+;nxi;z#i:;ixMM@@WWMnxxz**++++###zzzznnnnnxxxMMMWWWWWWWWWWWWWWMxxMMxxMWMMz+Wi,##;*x.*xMz`
//                                 #Mx:+n*#xM#*,+xMW###@@WMxnnzz###++*****iiiiii;;;;;iiiiii****++###zznW@xiWMMx;:i+xn#+,,nMM,
//                               `:#Mxn;:#zzx*;*nMW#################@@@@@@@@@@@@@@@@@@@@@W@@@@@@@@@@@@@@@@##MMMn;+#Wn#+,zxM+
//                              *M##WMMn*i;,.,+nMW@#########################################################@MMMn*::,:*nMWWWz;`
//                              n@###@MMxnz#znxMW@###########################################################@WMMxnnnxxMW@##@z`
//                              `.inM@@WWMMMMWW@###########################################@@##################@WWWMWWWW@@@x+,
//                                  `.****++##znx@WWMxnnnnzzzzzzzzz############+++++++++++++++++++**+++##znxx#iiii;;;:,.::,`
//                                              ````        `````````````````````````````````          `````
//
import java.io.*;
import java.lang.*;
import java.util.*;

public class C1303 {
    public static void main(String[] args) throws IOException{
        StringBuffer ans = new StringBuffer();
        StringTokenizer st;
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(f.readLine());

        int t = Integer.parseInt(st.nextToken());
        for(; t > 0; t--){
            st = new StringTokenizer(f.readLine());
            String str = st.nextToken();
            if(str.length() == 1){
                str+="a";
            }
            boolean[][] used = new boolean[26][26];
            HashMap<Integer, ArrayList<Integer>> hash = new HashMap<>();
            for(int i = 0; i < str.length() - 1; i++){
                int ft = str.charAt(i)-97;
                int sc = str.charAt(i+1)-97;
                if(!used[ft][sc]){
                    used[ft][sc] = true;
                    used[sc][ft] = true;
                    if(!hash.containsKey(ft))
                        hash.put(ft, new ArrayList<>());
                    if(!hash.containsKey(sc))
                        hash.put(sc, new ArrayList<>());
                    hash.get(ft).add(sc);
                    hash.get(sc).add(ft);
                }
            }
            StringBuilder op = new StringBuilder();
            int start = -1;
            boolean broken = false;
            for (int i = 0; i < 26; i++){
                if(hash.containsKey(i) && hash.get(i).size() == 1)
                    start = i;
                else if(hash.containsKey(i) && hash.get(i).size() >= 3)
                    broken = true;
            }
            if(broken || start == -1){
                ans.append("NO").append("\n"); continue;
            }
            op.append(Character.toString(start+97));
            int parent = -1;
            boolean[] visited = new boolean[26];
            visited[start] = true;
            while (parent != start){
                int bf = start;
                for(int i : hash.get(start)){
                    if(i != parent){
                        start = i;
                        break;
                    }
                }
                parent = bf;
                if(parent == start || visited[start]) break;
                visited[start] = true;
                op.append(Character.toString(start+97));
            }
            for(int i = 0; i < 26; i++){
                if(!visited[i])
                    op.append(Character.toString(i+97));
            }


            ans.append("YES").append("\n").append(op).append("\n");
        }

        f.close();



        System.out.println(ans);
    }

}