Rikka with String

12개 소문자로 이루어진 문자열의 각 접미사마다, 12개 문자의 순열을 재배치해 그 접미사가 사전순으로 가장 큰 접미사가 될 수 있는지 판정한다.

보통7문자열그리디정렬아직 제출이 없습니다시간 제한6초메모리 제한512 MB

문제

This is the last problem of this contest, so Rikka doesn't want to add a lengthy background to it. Let us make all the things simple and clear.

You have a string ss of length nn which only contains lowercase English letters from "a" to "l" (there are 1212 possible letters). You can choose a permutation of these 1212 letters p_a,p_b,,p_lp\_{\texttt{a}}, p\_{\texttt{b}}, \ldots, p\_{\texttt{l}}, and then consider the string t=p_s_1p_s_2p_s_nt = p\_{s\_1} p\_{s\_2} \ldots p\_{s\_n}. Your task is to check for each ii from 11 to nn whether the ii-th suffix (the substring t\[i,n]t\[i, n]) can become the largest suffix of tt in lexicographical order after such modification.

입력

The first line contains a single integer tt (1t1031 \leq t \leq 10^3), the number of test cases.

Each test case is given on a separate line containing a string ss (1s1051 \leq |s| \leq 10^5, the string contains only lowercase English letters from "a" to "l").

It is guaranteed that there are at most 1515 test cases with s>103|s| > 10^3.

출력

For each test case, output a single line with a binary string of length s|s|. If the ii-th suffix can become the largest one, the ii-th position must contain "1". Otherwise, it must contain "0".