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 cf1303c {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int T = Integer.parseInt(input.nextLine());
		for (int t = 0; t < T; t++) {
			String str = input.nextLine();
			Graph g = new Graph();
			Set<Character> charSet = new HashSet<>();
			Set<Character> alphaSet = new TreeSet<>();
			Map<Character, List<Character>> adj = new TreeMap<>();
			for (int i = 97; i < 123; i++) {
				alphaSet.add((char) i);
			}
			if (str.length() <= 1) {
				System.out.println("YES");
				String s = "";
				for (char c : alphaSet) {
					s = s + c;
				}
				System.out.println(s);
			} else {
				charSet.add(str.charAt(0));
				alphaSet.remove(str.charAt(0));
				adj.put(str.charAt(0), new ArrayList<>());
				for (int i = 1; i < str.length(); i++) {
					if (charSet.add(str.charAt(i))) {
						g.addNode(str.charAt(i));
						alphaSet.remove(str.charAt(i));
						adj.put(str.charAt(i), new ArrayList<>());
					}
					List<Character> neighbors = adj.get(str.charAt(i));
					if (!neighbors.contains(str.charAt(i-1))) {
						adj.get(str.charAt(i)).add(str.charAt(i-1));
					}
					List<Character> neighbors2 = adj.get(str.charAt(i-1));
					if (!neighbors2.contains(str.charAt(i))) {
						adj.get(str.charAt(i-1)).add(str.charAt(i));
					}
				}
				for (Character key : adj.keySet()) {
					List<Character> neighbors = adj.get(key);
					for(Character neighbor : neighbors) {
						if (key < neighbor) {
							g.addEdge(key, neighbor);
						}
					}
				}
				if (g.hasDegreeThree() || g.hasCycle()) {
					System.out.println("NO");
				} else {
					System.out.println("YES");
					String s = "";
					List<Character> traversal = g.dfsTree();
					for (char c : traversal) {
						s = s + c;
					}
					for (char c : alphaSet) {
						s = s + c;
					}
					System.out.println(s);
				}
			}
		}
	}
}

class Graph {
	List<Character> nodes;
	Map<Character, List<Character>> adj;

	public Graph () {
		nodes = new ArrayList<>();
		adj = new TreeMap<>();
	}

	public void addNode(char c) {
		nodes.add(c);
		ArrayList <Character> neighbors  = new ArrayList<>();
		adj.put(c, neighbors);
	}


	public void addEdge(char a, char b) {
		if (!nodes.contains(a)) {
			addNode(a);
		}
		if (!nodes.contains(b)) {
			addNode(b);
		}
		if (!adj.get(a).contains(b)) {
			adj.get(a).add(b);
		}
		if (!adj.get(b).contains(a)) {
			adj.get(b).add(a);
		}
	}

	public List<Character> getNodes() {
		return nodes;
	}

	public boolean hasCycle() {
		Map<Character, Boolean> explored = new TreeMap<>();
		for (Character c : nodes) {
			explored.put(c, false);
		}
		Character start = nodes.get(0);
		return cycleRecursive(start, explored, ' ');
	}

	private boolean cycleRecursive(Character curr, Map<Character, Boolean> explored, Character parent) 
    { 
        // Mark the current node as visited 
        explored.put(curr, true);
        Character c;
  
        // Recur for all the vertices adjacent to this vertex 
        Iterator<Character> it = adj.get(curr).iterator(); 
        while (it.hasNext()) 
        { 
            c = it.next(); 
  
            // If an adjacent is not visited, then recur for that 
            // adjacent 
            if (!explored.get(c)) 
            { 
                if (cycleRecursive(c, explored, curr)) 
                    return true; 
            } 
  
            // If an adjacent is visited and not parent of current 
            // vertex, then there is a cycle. 
            else if (c != parent) {
                return true; 
            }
        } 
        return false; 
    }

    private int degree(Character c) {
    	List<Character> neighbors = adj.get(c);
    	Set<Character> unique = new HashSet<>();
    	for (Character n : neighbors) {
    		unique.add(n);
    	}
    	return unique.size();
    }

	public boolean hasDegreeThree() {
		for (char c : nodes) {
			if (degree(c) >= 3) {
				return true;
			}
		}
		return false;
	}

	public List<Character> dfsTree () {
		char start = ' ';
		for (char c : nodes) {
			if (adj.get(c).size() == 1) {
				start = c;
			}
		}
		Map<Character, Boolean> explored = new TreeMap<>();
		for (Character c : nodes) {
			explored.put(c, false);
		}
		List<Character> answer = new ArrayList<>();
		Stack<Character> fringe = new Stack<>();
		fringe.push(start);
		Character curr = ' ';
		while (!fringe.isEmpty()) {
			curr = fringe.pop();
			if (!explored.get(curr)) {
				List<Character> neighbors = adj.get(curr);
				for (char c : neighbors) {
					if (explored.get(c) == false) {
						fringe.push(c);
					}
				}
				explored.put(curr, true);
				answer.add(curr);
			}
		}
		return answer;

	}
}