Dio Brando has set  a goal for himself of becoming the richest and the most powerful being on earth.To achieve his goals he will do anything using either manipulation,seduction or plain violence.
Only one guy stands between his goal of conquering earth ,named Jotaro Kujo aka JoJo .Now Dio has a stand (visual manifestation of life energy  i.e, special power )  “Za Warudo” ,which can stop time itself but needs to chant few words to activate the time stopping ability of the stand.There is a code hidden inside the words and if you can decipher the code then Dio loses his power.
In order to stop Dio ,Jotaro asks your help to decipher the code since he can’t do so while fighting Dio at the same time.
You will be given a string as input and you have to find the shortest substring which contains all the characters of itself and then make a number based on the alphabetical ordering of the characters.
For example : “bbbacdaddb”
shortest substring will be “bacd” and based on the alphabetical ordering
the answer is 2134

-----NOTE:-----
A substring is a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't substrings of this string. So the substring of the string s from position l to position r is

S[l;r]=SlSl+1…Sr.

-----Input :-----
The first line contains $T$,number of test cases.
The second line contains a string $S$.

-----Output:-----
For each test cases ,output the number you can get from the shortest string 

-----Constraints:-----
$1 \leq t \leq 100$
$1 \leq |S| \leq 10^6$

-----Test Cases:-----

-----Sample Input:-----
6

abcdfgh

urdrdrav

jojojojoj

bbbbaaa

cddfsccs

tttttttttttt   

-----Sample Output:-----
1234678

2118418418122

1015

21

46193

20

-----Explanation:-----
Test case 1: abcdfgh is the shortest substring containing all char of itself and the number is 1234678

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
import sys
import math
from collections import Counter
from collections import OrderedDict 
def inputt():
    return sys.stdin.readline().strip()
def printt(n):
    sys.stdout.write(str(n)+'\n')
def listt():
    return [int(i) for i in inputt().split()]
def gcd(a,b): 
   return math.gcd(a,b) 
 
def lcm(a,b): 
    return (a*b) / gcd(a,b) 
from collections import defaultdict   

def find_sub_string(str): 
    str_len = len(str) 
      
    # Count all distinct characters. 
    dist_count_char = len(set([x for x in str])) 
  
    ctr, start_pos, start_pos_index, min_len = 0, 0, -1, 9999999999
    curr_count = defaultdict(lambda: 0) 
    for i in range(str_len): 
        curr_count[str[i]] += 1
 
        if curr_count[str[i]] == 1: 
            ctr += 1
  
        if ctr == dist_count_char: 
            while curr_count[str[start_pos]] > 1: 
                if curr_count[str[start_pos]] > 1: 
                    curr_count[str[start_pos]] -= 1
                start_pos += 1
  
            len_window = i - start_pos + 1
            if min_len > len_window: 
                min_len = len_window 
                start_pos_index = start_pos 
    return str[start_pos_index: start_pos_index + min_len]
t= int(inputt())
for _ in range(t):
    j=[]
    str1 =inputt()
    s=find_sub_string(str1) 
    for i in s:
        j.append(abs(97-ord(i))+1)
    st = [str(i) for i in j]
    print(''.join(st))     




# https://www.geeksforgeeks.org/smallest-window-contains-characters-string/
from collections import defaultdict

MAX_CHARS = 256

def solve(strr):
    n = len(strr)

    dist_count = len(set([x for x in strr]))

    curr_count = defaultdict(lambda: 0)
    count = 0
    start = 0
    min_len = n

    start_index = 0

    for j in range(n):
        curr_count[strr[j]] += 1

        if curr_count[strr[j]] == 1:
            count += 1

        if count == dist_count:
            while curr_count[strr[start]] > 1:
                if curr_count[strr[start]] > 1:
                    curr_count[strr[start]] -= 1

                start += 1

            len_window = j - start + 1

            if min_len > len_window:
                min_len = len_window
                start_index = start

    return str(strr[start_index: start_index + min_len])

for _ in range(int(input())):
    x = solve(input().strip())

    print(''.join(str(ord(c) - ord('a') + 1) for c in x))