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 = "# https://www.geeksforgeeks.org/smallest-window-contains-characters-string/\r\nfrom collections import defaultdict\r\n\r\nMAX_CHARS = 256\r\n\r\ndef solve(strr):\r\n    n = len(strr)\r\n\r\n    dist_count = len(set([x for x in strr]))\r\n\r\n    curr_count = defaultdict(lambda: 0)\r\n    count = 0\r\n    start = 0\r\n    min_len = n\r\n\r\n    start_index = 0\r\n\r\n    for j in range(n):\r\n        curr_count[strr[j]] += 1\r\n\r\n        if curr_count[strr[j]] == 1:\r\n            count += 1\r\n\r\n        if count == dist_count:\r\n            while curr_count[strr[start]] > 1:\r\n                if curr_count[strr[start]] > 1:\r\n                    curr_count[strr[start]] -= 1\r\n\r\n                start += 1\r\n\r\n            len_window = j - start + 1\r\n\r\n            if min_len > len_window:\r\n                min_len = len_window\r\n                start_index = start\r\n\r\n    return str(strr[start_index: start_index + min_len])\r\n\r\nfor _ in range(int(input())):\r\n    x = solve(input().strip())\r\n\r\n    print(''.join(str(ord(c) - ord('a') + 1) for c in x))\r\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13655