{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\n In this problem, you are given a string s and q queries.\n \u003cbr\u003e \n \u003cbr\u003e For each query, you should answer that when all distinct \n \u003cspan\u003esubstrings\u003c/span\u003e of string s were sorted lexicographically, which one is the \n \u003cspan\u003ek-th\u003c/span\u003e smallest.\n \u003cbr\u003e \n \u003cbr\u003e A \n \u003cspan\u003esubstring\u003c/span\u003e s \n \u003csub\u003ei...j\u003c/sub\u003e of the string s \u003d a \n \u003cspan\u003e\u003csub\u003e1\u003c/sub\u003ea\u003c/span\u003e \n \u003csub\u003e2\u003c/sub\u003e ...a \n \u003csub\u003en\u003c/sub\u003e(1 ≤ i ≤ j ≤ n) is the string a \n \u003cspan\u003e\u003csub\u003ei\u003c/sub\u003ea\u003c/span\u003e \n \u003csub\u003ei+1\u003c/sub\u003e ...a \n \u003csub\u003ej\u003c/sub\u003e. Two \n \u003cspan\u003esubstrings\u003c/span\u003e s \n \u003csub\u003ex...y\u003c/sub\u003e and s \n \u003csub\u003ez...w\u003c/sub\u003e are \n \u003cspan\u003ecosidered\u003c/span\u003e to be distinct if s \n \u003csub\u003ex...y\u003c/sub\u003e ≠ S \n \u003csub\u003ez...w\u003c/sub\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003e\n The input consists of multiple test cases.Please process till \n \u003cspan\u003eEOF\u003c/span\u003e.\n \u003cbr\u003e \n \u003cbr\u003e Each test case begins with a line containing a string s(|s| ≤ 10 \n \u003csup\u003e5\u003c/sup\u003e) with only lowercase letters.\n \u003cbr\u003e \n \u003cbr\u003e Next line contains a \n \u003cspan\u003epostive\u003c/span\u003e integer q(1 ≤ q ≤ 10 \n \u003csup\u003e5\u003c/sup\u003e), the number of questions.\n \u003cbr\u003e \n \u003cbr\u003e q queries are given in the next q lines. Every line contains an integer v. You should calculate the k by k \u003d (l \n \u003cspan\u003eXOR\u003c/span\u003e r \n \u003cspan\u003eXOR\u003c/span\u003e v)+1(l, r is the output of previous question, at the beginning of each case l \u003d r \u003d 0, 0 \u0026lt; k \u0026lt; 2 \n \u003csup\u003e63\u003c/sup\u003e, \n \u003cspan\u003e“XOR”\u003c/span\u003e denotes exclusive or)\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv\u003e\n For each test case, output consists of q lines, the \n \u003cspan\u003ei-th\u003c/span\u003e line contains two integers l, r which is the answer to the \n \u003cspan\u003ei-th\u003c/span\u003e query. (The answer l,r satisfies that s \n \u003csub\u003el...r\u003c/sub\u003e is the \n \u003cspan\u003ek-th\u003c/span\u003e smallest and if there are several l,r available, \n \u003cspan\u003eouput\u003c/span\u003e l,r which with the smallest l. If there is no l,r satisfied, output “0 0”. Note that s \n \u003csub\u003e1...n\u003c/sub\u003e is the whole string)\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cdiv\u003e \n \u003cpre\u003e\r\n\t\u003c/pre\u003e \n \u003cdiv\u003e \n \u003cpre\u003e\r\n\t\t\u003cspan\u003eaaa\u003c/span\u003e\r\n4\r\n0\r\n2\r\n3\r\n5 \u003c/pre\u003e \n \u003c/div\u003e \n\u003c/div\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cdiv\u003e \n \u003cpre\u003e\r\n\t\u003c/pre\u003e \n \u003cdiv\u003e \n \u003cpre\u003e\r\n\t\t1 1\r\n1 3\r\n1 2\r\n0 0 \u003c/pre\u003e \n \u003c/div\u003e \n\u003c/div\u003e"}}]}