{"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假设 s\u003d$s_1$ $s_2$$ \\cdots $$s_n$ 是长度为 n 的字符串。对于 1 到 n 之间的任何整数 k,s 的 $k^{th}$ 后缀被定义为 $s_k$ $s_{k+1}$$ \\cdots $$s_n$。例如,“contest”的 $4^{th}$ 后缀是“test”,“suffix”的 $1^{st}$ 后缀是“suffix”本身。\u003cbr\u003e\u003cbr\u003e可以考虑 s 的字典序最小的后缀。假设该 $k^{th}$ 后缀在所有 s 的后缀中是字典序最小的。方便起见,我们称这样的 k 为 s 的最小索引。给定一个字符串 t\u003d$t_1$ $t_2 \\cdots t_n$,你的任务是计算所有 i\u003d1,2,3,$ \\cdots $,n 上 (最小索引的 $t_1$ $t_2 \\cdots t_i$)$ \\cdot 1112^{i-1}$ 的总和。这个值可能很大,你只需要按照模 $10^9$+7 的规则输出结果。\u003cbr\u003e\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"输入的第一行包含一个整数 T (1≤T≤10 000),表示测试用例的数量。接下来的 T 行中,每行包含一个最多包含 $10^6$ 个小写英文字母的非空字符串。所有测试用例中字符串的总长度不超过 $2 \\cdot 10^7$。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,你应该在单独的一行中输出答案。"}},{"title":"样例","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\u003e1\r\naab\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1238769\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"提示","value":{"format":"HTML","content":"\u003cbr\u003e“a”, “aa”, “aab”的最小索引分别为 1, 2, 1。因此答案为 (1+2\u0026amp;#8729;1112+1112^2) mod (10^9+7)\u003d1238769。\u003cbr\u003e"}}]}