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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class solution {
	static ArrayList<Integer> adjList[];
	static boolean vis[];
	static StringBuilder sb;
	static ArrayList<Integer> potentialStart;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int t = sc.nextInt();
		out: while (t-- > 0) {
			adjList = new ArrayList[26];
			vis = new boolean[26];
			sb = new StringBuilder();
			potentialStart = new ArrayList<Integer>();
			for (int i = 0; i < 26; i++) {
				adjList[i] = new ArrayList<Integer>();
			}
			char s[] = sc.nextLine().toCharArray();

			if (s.length > 1) {
				adjList[s[0] - 'a'].add(s[1] - 'a');
				if (!adjList[s[s.length - 1] - 'a'].contains(s[s.length - 2] - 'a'))
					adjList[s[s.length - 1] - 'a'].add(s[s.length - 2] - 'a');

			} else {
				for (int i = 0; i < 26; i++) {
					if (!vis[i])
						sb.append((char) (i + 'a'));
				}
				pw.println("YES");
				pw.println(sb);
				continue;

			}

			for (int i = 1; i < s.length - 1; i++) {
				int c1 = s[i] - 'a';
				int c2 = s[i - 1] - 'a';
				int c3 = s[i + 1] - 'a';
				if (!adjList[c1].contains(c2) && c1 != c2)
					adjList[c1].add(c2);
				if (!adjList[c1].contains(c3) && c1 != c3)
					adjList[c1].add(c3);
				if (adjList[c1].size() > 2) {
					pw.println("NO");
					continue out;
				}
			}

			for (int i = 0; i < 26; i++) {
				if (adjList[i].size() == 1) {
					potentialStart.add(i);
				}
			}
			if (potentialStart.size() % 2 == 1 || potentialStart.size() == 0) {
				pw.println("NO");
				continue;
			} else
				pw.println("YES");
			for (int i = 0; i < potentialStart.size(); i++) {
				if (!vis[potentialStart.get(i)])
					dfs(potentialStart.get(i));

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

	public static void dfs(int start) {
		if (vis[start])
			return;
		vis[start] = true;
		sb.append((char) (start + 'a'));
		for (int c : adjList[start]) {
			if (vis[c])
				continue;
			dfs(c);
		}

	}
}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s) {
		br = new BufferedReader(new InputStreamReader(s));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public double nextDouble() throws IOException {
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if (x.charAt(0) == '-') {
			neg = true;
			start++;
		}
		for (int i = start; i < x.length(); i++)
			if (x.charAt(i) == '.') {
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			} else {
				sb.append(x.charAt(i));
				if (dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg ? -1 : 1);
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

}