12개 소문자로 이루어진 문자열의 각 접미사마다, 12개 문자의 순열을 재배치해 그 접미사가 사전순으로 가장 큰 접미사가 될 수 있는지 판정한다.
보통7문자열그리디정렬아직 제출이 없습니다시간 제한6초메모리 제한512 MBThis 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 s of length n which only contains lowercase English letters from "a" to "l" (there are 12 possible letters). You can choose a permutation of these 12 letters p_a,p_b,…,p_l, and then consider the string t=p_s_1p_s_2…p_s_n. Your task is to check for each i from 1 to n whether the i-th suffix (the substring t\[i,n]) can become the largest suffix of t in lexicographical order after such modification.
The first line contains a single integer t (1≤t≤103), the number of test cases.
Each test case is given on a separate line containing a string s (1≤∣s∣≤105, the string contains only lowercase English letters from "a" to "l").
It is guaranteed that there are at most 15 test cases with ∣s∣>103.
For each test case, output a single line with a binary string of length ∣s∣. If the i-th suffix can become the largest one, the i-th position must contain "1". Otherwise, it must contain "0".