{"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\"\u003eYou are given a string $S$ consisting of only lowercase english letters and some queries.\u003cbr\u003e\u003cbr\u003eFor each query $(l, r, k)$, please output the starting position of the k-th occurence of the substring $S_lS_{l+1}...S_r$ in S.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer $T(1 \\leq T \\leq 20)$, denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eThe first line of each test case contains two integer $N(1 \\leq N \\leq 10^5), Q(1 \\leq Q \\leq 10^5)$, denoting the length of $S$ and the number of queries.\u003cbr\u003e\u003cbr\u003eThe second line of each test case contains a string $S(|S|\u003dN)$ consisting of only lowercase english letters.\u003cbr\u003e\u003cbr\u003eThen $Q$ lines follow, each line contains three integer $l, r(1 \\leq l \\leq r \\leq N)$ and $k(1 \\leq k \\leq N)$, denoting a query.\u003cbr\u003e\u003cbr\u003eThere are at most $5$ testcases which $N$ is greater than $10^3$."}},{"title":"Output","value":{"format":"HTML","content":"For each query, output the starting position of the k-th occurence of the given substring.\u003cbr\u003e\u003cbr\u003eIf such position don\u0027t exists, output $-1$ instead."}},{"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\n12 6\r\naaabaabaaaab\r\n3 3 4\r\n2 3 2\r\n7 8 3\r\n3 4 2\r\n1 4 2\r\n8 12 1\r\n1 1\r\na\r\n1 1 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n2\r\n-1\r\n6\r\n9\r\n8\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}