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

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "# cook your dish here\nimport sys\nimport math\nfrom collections import Counter\nfrom collections import OrderedDict \ndef inputt():\n    return sys.stdin.readline().strip()\ndef printt(n):\n    sys.stdout.write(str(n)+'\\n')\ndef listt():\n    return [int(i) for i in inputt().split()]\ndef gcd(a,b): \n   return math.gcd(a,b) \n \ndef lcm(a,b): \n    return (a*b) / gcd(a,b) \nfrom collections import defaultdict   \n\ndef find_sub_string(str): \n    str_len = len(str) \n      \n    # Count all distinct characters. \n    dist_count_char = len(set([x for x in str])) \n  \n    ctr, start_pos, start_pos_index, min_len = 0, 0, -1, 9999999999\n    curr_count = defaultdict(lambda: 0) \n    for i in range(str_len): \n        curr_count[str[i]] += 1\n \n        if curr_count[str[i]] == 1: \n            ctr += 1\n  \n        if ctr == dist_count_char: \n            while curr_count[str[start_pos]] > 1: \n                if curr_count[str[start_pos]] > 1: \n                    curr_count[str[start_pos]] -= 1\n                start_pos += 1\n  \n            len_window = i - start_pos + 1\n            if min_len > len_window: \n                min_len = len_window \n                start_pos_index = start_pos \n    return str[start_pos_index: start_pos_index + min_len]\nt= int(inputt())\nfor _ in range(t):\n    j=[]\n    str1 =inputt()\n    s=find_sub_string(str1) \n    for i in s:\n        j.append(abs(97-ord(i))+1)\n    st = [str(i) for i in j]\n    print(''.join(st))     \n\n\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14907