{"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\"\u003eFor a string $S \u003d s_{1}s_{2}\\cdots s_{N}$, the period of S is defined as the smallest positive integer p \u0026lt;\u003d N, such that si+p \u003d si holds for all 1 \u0026lt;\u003d i \u0026lt;\u003d N – p. Now given two integers L and R (1 \u0026lt;\u003d L \u0026lt;\u003d R \u0026lt;\u003d N), you are asked to find out the period of $s_{L}s_{L+1}\\cdots s_{R}$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input begins with an integer T (T \u0026lt;\u003d 20), indicating the number of test case. The first line of each case contains a string S, which consists of N (1 \u0026lt;\u003d N \u0026lt;\u003d 100000) lowercase English letters. The second line contains an integer Q (1 \u0026lt;\u003d N \u0026lt;\u003d 100000), indicating the number of queries. The following Q lines each contain two integers L and R (1 \u0026lt;\u003d L \u0026lt;\u003d R \u0026lt;\u003d N).\u003cbr\u003e\u003cbr\u003eThe total length of all the strings is not larger than 500000, and the total number of queries is not larger than 200000.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each case, output \"Case #X:\" in a line where X is the case number, staring from 1. Then for each query, output the answer in a line."}},{"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\u003e2\r\naaabaa\r\n3\r\n1 3\r\n1 4\r\n2 5\r\nabcabcabc\r\n1\r\n1 9\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n1\r\n4\r\n3\r\nCase #2:\r\n3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}