In this problem, you are given a string s and q queries.
For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is the k-th smallest.
A substring s
i...j of the string s = a
1a
2 ...a
n(1 ≤ i ≤ j ≤ n) is the string a
ia
i+1 ...a
j. Two substrings s
x...y and s
z...w are cosidered to be distinct if s
x...y ≠ S
z...w
The input consists of multiple test cases.Please process till EOF.
Each test case begins with a line containing a string s(|s| ≤ 10
5) with only lowercase letters.
Next line contains a postive integer q(1 ≤ q ≤ 10
5), the number of questions.
q queries are given in the next q lines. Every line contains an integer v. You should calculate the k by k = (l⊕r⊕v)+1(l, r is the output of previous question, at the beginning of each case l = r = 0, 0 < k < 2
63, “⊕” denotes exclusive or)
For each test case, output consists of q lines, the i-th line contains two integers l, r which is the answer to the i-th query. (The answer l,r satisfies that s
l...r is the k-th smallest and if there are several l,r available, ouput l,r which with the smallest l. If there is no l,r satisfied, output “0 0”. Note that s
1...n is the whole string)