{"trustable":true,"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 class\u003d\"panel_content\"\u003e In this problem, you are given a string s and q queries.\u003cbr\u003e\u003cbr\u003e For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is the k-th smallest. \u003cbr\u003e\u003cbr\u003e A substring s\u003csub\u003ei...j\u003c/sub\u003e of the string s \u003d a\u003csub\u003e1\u003c/sub\u003ea\u003csub\u003e2\u003c/sub\u003e ...a\u003csub\u003en\u003c/sub\u003e(1 ≤ i ≤ j ≤ n) is the string a\u003csub\u003ei\u003c/sub\u003ea\u003csub\u003ei+1\u003c/sub\u003e ...a\u003csub\u003ej\u003c/sub\u003e. Two substrings s\u003csub\u003ex...y\u003c/sub\u003e and s\u003csub\u003ez...w\u003c/sub\u003e are cosidered to be distinct if s\u003csub\u003ex...y\u003c/sub\u003e ≠ S\u003csub\u003ez...w\u003c/sub\u003e\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" The input consists of multiple test cases.Please process till EOF. \u003cbr\u003e\u003cbr\u003e Each test case begins with a line containing a string s(|s| ≤ 10\u003csup\u003e5\u003c/sup\u003e) with only lowercase letters.\u003cbr\u003e\u003cbr\u003e Next line contains a postive integer q(1 ≤ q ≤ 10\u003csup\u003e5\u003c/sup\u003e), the number of questions.\u003cbr\u003e \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♁r♁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\u003csup\u003e63\u003c/sup\u003e, “♁” denotes exclusive or)\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":" 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\u003csub\u003el...r\u003c/sub\u003e 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\u003csub\u003e1...n\u003c/sub\u003e is the whole string)\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eaaa\r\n4\r\n0\r\n2\r\n3\r\n5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 1\r\n1 3\r\n1 2\r\n0 0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}