{"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\"\u003eAlice wants to send a classified message to Bob. She tries to encrypt the message with her original encryption method. The message is a string $S$, which consists of $N$ lowercase letters.\u003cbr\u003e\u003cbr\u003e$S[a…b]$ means a substring of S ranging from $S[a]$ to $S[b]$ ($0≤a≤b\u0026lt;N$). If the first $i$ letters have been encrypted, Alice will try to find a magic string $P$. Assuming $P$ has $K$ letters, $P$ is the longest string which satisfies $P\u003dS[T...T+K-1]$ ($0≤T\u0026lt;i$,$T+K≤N$) and $P\u003dS[i…i+K-1] (i+K≤N)$. In other words, $P$ is a substring of $S$, of which starting address is within $[0...i-1]$, and $P$ is also a prefix of $S[i...N-1]$. If $P$ exists, Alice will append integer $K$ and $T$ to ciphertext. If $T$ is not unique, Alice would select the minimal one. And then $i$ is incremented by $K$. If $P$ does not exist, Alice will append -1 and the ASCII code of letter $S[i]$ to ciphertext, and then increment $i$ by 1.\u003cbr\u003e\u003cbr\u003eObviously the first letter cannot be encrypted. That is to say, $P$ does not exist when $i\u003d0$. So the first integer of ciphertext must be -1, and the second integer is the ASCII code of $S[0]$.\u003cbr\u003e\u003cbr\u003eWhen $i\u003dN$, all letters are encrypted, and Alice gets the final ciphertext, which consists of many pairs of integers. Please help Alice to implement this method.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input contains an integer $T$, which represents the number of test cases ($T≤50$). Each test case contains a line of string, which has no more than 100000 lowercase letters. It is guaranteed that the total length of the strings is not greater than $2×10^6$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a single line consisting of “\u003cb\u003eCase #X:\u003c/b\u003e” first. $X$ is the test case number starting from 1. Output the ciphertext in the following lines. Each line contains two integers separated by a single space."}},{"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\naaaaaa\r\naaaaabbbbbaaabbc\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n-1 97\r\n5 0\r\nCase #2:\r\n-1 97\r\n4 0\r\n-1 98\r\n4 5\r\n5 2\r\n-1 99\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}