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 javafx.util.Pair;

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main implements Runnable
{
    boolean multiple = true;
    long MOD = 1000000007;

    @SuppressWarnings("Duplicates")
    void solve() throws Exception
    {
        String s = sc.nextToken();
        int[] ans = new int[200];
        for (int i = 0; i < 200; i++)
        {
            ans[i] = -1;
        }

        boolean[] used = new boolean[26];
        int ptr = 100;
        ans[ptr] = s.charAt(0) - 'a';
        used[s.charAt(0) - 'a'] = true;

        for (int i = 1; i < s.length(); i++)
        {
            int target = s.charAt(i) - 'a';
            if (ans[ptr - 1] == target)
                ptr--;
            else if (ans[ptr + 1] == target)
                ptr++;
            else if (used[target])
            {
//                System.out.println("here");
//                System.out.println(i);
//                System.out.println(ptr);
//                System.out.println(ans[ptr - 1]);
//                System.out.println(target);
                System.out.println("NO");
                return;
            }
            else if (ans[ptr - 1] == -1)
            {
                ptr--;
                ans[ptr] = target;
            }
            else if (ans[ptr + 1] == -1)
            {
                ptr++;
                ans[ptr] = target;
            }
            else
            {
                System.out.println("NO");
                return;
            }
            used[target] = true;
        }

        System.out.println("YES");
        for (int an : ans)
        {
            if (an != -1) System.out.print((char)(an + 'a'));
        }
        for (int i = 0; i < 26; i++)
        {
            if (!used[i])
                System.out.print((char)(i + 'a'));
        }
        System.out.println();
    }

    int nck(int n, int k)
    {
        return factorial(n) / (factorial(n - k) * factorial(k));
    }

    int factorial(int n)
    {
        return (n <= 1) ? 1 : n * factorial(n - 1);
    }

    long[][] pow(long[][] a, long pow)
    {
        if (pow == 0)
        {
            long[][] identity = new long[a.length][a.length];
            for (int i = 0; i < a.length; i++)
                identity[i][i] = 1;
            return identity;
        }
        if (pow == 1) return a;
        long[][] temp = pow(a, pow / 2);
        temp = mult(temp, temp);
        if (pow % 2 == 0) return temp;
        return mult(a, temp);
    }

    long[][] mult(long[][] a, long[][] b)
    {
        if (a[0].length != b.length)
            a[0][0] /= 0;
        long[][] c = new long[a.length][b[0].length];
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < b[0].length; j++)
                for (int k = 0; k < a[0].length; k++)
                    c[i][j] = (c[i][j] + ((a[i][k] * b[k][j]) % MOD)) % MOD;
        return c;
    }

    long totient(long m)
    {
        long result = m;
        for (long i = 2; i * i <= m; i++)
            if (m % i == 0)
            {
                while (m % i == 0)
                    m /= i;
                result -= result / i;
            }
        if (m > 1)
            result -= result / m;
        return result;
    }

    long inv(long a, long b)
    {
        return 1 < a ? b - inv(b % a, a) * b / a : 1;
    }

    long gcd(long a, long b)
    {
        return a == 0 ? b : gcd(b % a, a);
    }

    long lcm(long a, long b)
    {
        return (a * b) / gcd(a, b);
    }

    class SegTree
    {
        long[][] ans;

        SegTree()
        {

        }
    }

    class SegNode
    {
        int max;
        int L, R;
        SegNode left = null, right = null;

        int query(int queryL, int queryR)
        {
            if (queryL == L && queryR == R)
                return max;

            int leftAns = Integer.MIN_VALUE, rightAns = Integer.MIN_VALUE;
            if (left != null && queryL <= left.R)
                leftAns = left.query(queryL, min(queryR, left.R));
            if (right != null && queryR >= right.L)
                rightAns = right.query(max(queryL, right.L), queryR);

            return max(leftAns, rightAns);
        }

        SegNode(int[] arr, int l, int r)
        {
            L = l;
            R = r;
            max = arr[l];

            if (l == r) return;

            int mid = (l + r) / 2;
            left = new SegNode(arr, l, mid);
            right = new SegNode(arr, mid + 1, r);
            max = max(left.max, right.max);
        }
    }

    void print(long[] arr)
    {
        for (int i = 0; i < arr.length; i++)
            System.out.print(arr[i] + " ");
        System.out.println();
    }

    @Override
    public void run()
    {
        try
        {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            sc = new FastScanner(in);
            if (multiple)
            {
                int q = sc.nextInt();
                for (int i = 0; i < q; i++)
                    solve();
            } else
                solve();
        } catch (Throwable uncaught)
        {
            Main.uncaught = uncaught;
        } finally
        {
            out.close();
        }
    }

    public static void main(String[] args) throws Throwable
    {
        Thread thread = new Thread(null, new Main(), "", (1 << 26));
        thread.start();
        thread.join();
        if (Main.uncaught != null)
        {
            throw Main.uncaught;
        }
    }

    static Throwable uncaught;
    BufferedReader in;
    FastScanner sc;
    PrintWriter out;
}

class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in)
    {
        this.in = in;
    }

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

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}