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.*;
import java.util.*;
import java.math.*;

public class p1303C {

	public class Node {
		public int letter;
		public ArrayList<Node> neighbors;
		public int depth;
		public int visitedby;

		public Node(int letter) {
			this.letter = letter;
			neighbors = new ArrayList<Node>();
			depth = 0;
			visitedby = -1;
		}

		public String toString() {
			String ret = "" + (char) (letter + 'a');

			ret += ": ";

			for(Node neighbor : neighbors) {
				ret += (char)(neighbor.letter + 'a') + ", ";
			}

			return ret;
		}
				
	}
		

	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int T = Integer.parseInt(ar[0]);
	for(int t = 0; t < T; t++) {
		in = fin.readLine();
		int n = in.length();

		boolean[][] adj = new boolean[26][26];

		ArrayList<Node> nodes = new ArrayList<Node>();
		for(int i = 0; i < 26; i++) {
			nodes.add(new Node(i));
		}

		boolean[][] hasedge = new boolean[26][26];

		for(int i = 0; i < n - 1; i++) {
			adj[in.charAt(i) - 'a'][in.charAt(i+1) - 'a'] = true;
			adj[in.charAt(i+1) - 'a'][in.charAt(i) - 'a'] = true;

			if(!hasedge[in.charAt(i) - 'a'][in.charAt(i+1) - 'a']) {
				nodes.get(in.charAt(i) - 'a').neighbors.add(nodes.get(in.charAt(i+1) - 'a'));
				nodes.get(in.charAt(i+1) - 'a').neighbors.add(nodes.get(in.charAt(i) - 'a'));

				hasedge[in.charAt(i) - 'a'][in.charAt(i+1) - 'a'] = true;
				hasedge[in.charAt(i+1) - 'a'][in.charAt(i) - 'a'] = true;
			}

		}

		int[] numadj = new int[26];

		for(int i = 0; i < 26; i++) {
			for(int j = 0; j < 26; j++) {
				if(adj[i][j]) {
					numadj[i]++;
				}
			}
		}

		boolean fail = false;

		for(int i = 0; i < 26 && !fail; i++) {
			if(numadj[i] > 2) {
				System.out.println("NO");
				fail = true;
			}
		}

		if(fail) {
			continue;
		}

		//System.err.println(nodes);


		for(int i = 0; i < 26; i++) {
			boolean[] visited = new boolean[26];

			//visited[i] = true;
			
			for(Node node : nodes) {
				node.depth = 0;
				node.visitedby = -1;
			}

			//ArrayList<Integer> tovisit = new ArrayList<Integer>();
			Stack<Integer> tovisit = new Stack<Integer>();

			for(Node neighbor : nodes.get(i).neighbors) {
				tovisit.push(neighbor.letter);
				//visited[neighbor.letter] = true;

				neighbor.depth = 1;
				neighbor.visitedby = i;
			}

			int tovisitind = 0;

			while(!tovisit.empty()) {
				Node node = nodes.get( (int) tovisit.pop());

					if(node.letter == i ){
						
							fail = true;
						
					}

				visited[node.letter] = true;

				if(i == 0) {
					//System.err.println("visiting: " + node.letter + " ; " + node.depth);
				}

				for(Node neighbor : node.neighbors) {
					

					
						if(neighbor.visitedby != node.letter && node.visitedby != neighbor.letter) {
							tovisit.push(neighbor.letter);
							neighbor.visitedby = node.letter;
						}

					/*if(!visited[neighbor.letter]) {
						visited[neighbor.letter] = true;

						tovisit.add(neighbor.letter);
						neighbor.depth = node.depth + 1;
						neighbor.visitedby = node.letter;
					}*/
				}

				tovisitind++;
			}
		}

		if(fail) {
			System.out.println("NO");
			continue;
		}

		StringBuilder sb = new StringBuilder("");

		boolean[] visited = new boolean[26];

		for(int i = 0; i < 26; i++) {
			if(visited[i]) {
				continue;
			}

			if(nodes.get(i).neighbors.size() == 1) {
				sb.append( (char) ('a' + i));
				
				visited[i] = true;

				ArrayList<Integer> tovisit = new ArrayList<Integer>();

			for(Node neighbor : nodes.get(i).neighbors) {
				tovisit.add(neighbor.letter);
				visited[neighbor.letter] = true;

				neighbor.depth = 1;
			}

			int tovisitind = 0;

			while(tovisitind < tovisit.size()) {
				Node node = nodes.get(tovisit.get(tovisitind));
				sb.append( (char) ('a' + node.letter) );

				for(Node neighbor : node.neighbors) {
					
					if(!visited[neighbor.letter]) {
						visited[neighbor.letter] = true;
						

						tovisit.add(neighbor.letter);
					}
				}

				tovisitind++;
			}
		
			}
		}

		for(int i = 0; i < 26; i++) {
			if(!visited[i]) {
				sb.append( (char) ('a' + i));
			}
		}

		System.out.println("YES");
		System.out.println(sb);

	}



		
				



	}


	public static void main(String[] args) throws Exception {
		p1303C a = new p1303C();
		a.realMain();
	}
}