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.util.*;
public class Main{
    
    
        static StringBuffer ans;
        static HashMap<Character,ArrayList<Character>> map;
        
        static StringBuffer dfs(char s,boolean visited[]){
            // System.out.println(ans);
            ans.append(s);
            ArrayList<Character> temp= new ArrayList<>();
            temp=map.get(s);
            visited[s-'a'] = true;
            for(int i=0;i<temp.size();i++){
                char d=temp.get(i);
                 if(!visited[d-'a'])
                 dfs(d,visited);
            }
           return ans;
            
        }
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        while(test-- >0){
            ans=new StringBuffer("");
             map=new HashMap<>();
            HashSet<Character> set=new HashSet<>();
            String a=sc.next();
            boolean flag=true;
            char str[]=a.toCharArray();
            int n=str.length;
            StringBuffer ans=new StringBuffer();
            if(n == 1){
                for(int i=0;i<26;i++) 
                ans.append((char)(i+'a'));
                System.out.println("YES");
                System.out.println(ans);
                continue;
            }
            for(int i=0;i<n;i++){
                char ch=str[i];
                if(!map.containsKey(ch)){
                    ArrayList<Character> s=new ArrayList<>();
                    if(i>0) s.add(str[i-1]);
                    if(i<n-1) {
                        if(!s.contains(str[i+1]))
                        s.add(str[i+1]);
                    }
                    if(s.size() == 1) set.add(ch);
                    map.put(ch,s);
                    
                }
                else{
                    ArrayList<Character> temp=new ArrayList<>();
                    temp=map.get(ch);
                    int size=temp.size();
                    if(size == 2){
                       if(i<n-1){
                           char prv=str[i-1];
                           char nxt=str[i+1];
                           if(temp.contains(prv)&& temp.contains(nxt)) continue;
                           else{
                               flag=false;
                               break;
                           }
                       }
                       if(i == n-1){
                            char prv=str[i-1];
                            if(temp.contains(prv)) continue;
                            else{
                               flag=false;
                               break;
                           }
                       }
                    }
                    if(size == 1){
                         if(i<n-1){
                           char prv=str[i-1];
                           char nxt=str[i+1];
                           if(!temp.contains(prv)&&!temp.contains(nxt)) {
                                flag=false;
                                break;
                           }
                           else if(prv != nxt){
                              if(temp.contains(prv)){ temp.add(nxt);}
                              else if(temp.contains(nxt)){ temp.add(prv);}
                              map.put(ch,temp);
                              set.remove(ch);
                           }
                       }
                       else {
                         char prv=str[i-1];
                         if(!temp.contains(prv)) {
                                temp.add(prv);
                                map.put(ch,temp);
                                set.remove(ch);
                           }
                       }
                    }
                }
            }
            
       
        // System.out.println(map);
            if(set.isEmpty() || !flag){
                System.out.println("NO");
                continue;
            }
            System.out.println("YES");
             Character temp= set.iterator().next();
            boolean visited[]=new boolean[26];
            ans= dfs(temp,visited);
            // System.out.println("...");
            for(int i=0;i<26;i++) 
            if(!visited[i])
            ans.append((char)(i+'a'));
            System.out.println(ans);
        }
    }
}