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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Arrays;
public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int tests = in.nextInt();

    testLoop:
    for (int test = 0; test < tests; test++) {
      String s = in.next();

      HashMap<Character, HashSet<Character>> adj = new HashMap<>();
      HashSet<Character> added = new HashSet<>();
      StringBuilder sb = new StringBuilder();

      for (char c = 'a'; c <= 'z'; c++)
        adj.put(c, new HashSet<>());

      for (int i = 0; i < s.length(); i++) {
        if (i > 0)
          adj.get(s.charAt(i)).add(s.charAt(i - 1));
        if (i < s.length() - 1)
          adj.get(s.charAt(i)).add(s.charAt(i + 1));
        if (adj.get(s.charAt(i)).size() > 2) {
          out.println("NO");
          continue testLoop;
        }
      }

      char start = '/';
      boolean all0 = true;

      for (char c : adj.keySet()) {
        if (adj.get(c).size() > 0)
          all0 = false;
        if (adj.get(c).size() == 1) {
          start = c;
          break;
        }
      }

      if (start == '/') {
        if (all0) {
          out.println("YES");
          for (char c : adj.keySet()) {
            out.print(c);
          }
          out.println();
        } else {
          out.println("NO");
        }
        continue testLoop;
      }

      if (!build(start, adj, added, sb)) {
        out.println("NO");
        continue testLoop;
      }

      for (char c : adj.keySet()) {
        if (!added.contains(c))
          sb.append(c);
      }

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

    }

    out.close();
  }

  static boolean build(char cur, HashMap<Character, HashSet<Character>> adj, HashSet<Character> added, StringBuilder sb) {
    sb.append(cur);
    added.add(cur);
    boolean found = false;
    boolean ret = true;
    for (char c : adj.get(cur)) {
      if (!added.contains(c)) {
        if (found) {
          return false;
        }
        found = true;
        ret = build(c, adj, added, sb);
      }
    }
    return ret;
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }

  static void print(int[] arr) {
    Arrays.stream(arr).forEach(i -> System.out.print(i + " "));
    System.out.println();
  }

  public static int[] mergeSort(int[] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[] left = new int[mid];
    int[] right = new int[a.length - mid];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[] merge(int[] l, int[] r) {
    int[] merged = new int[l.length + r.length];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i] <= r[j])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }

}