{"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\"\u003eJ likes playing electric guitar, especially the famous guitar model - Gibson SG Standard. He always composes music with his Gibson SG Standard.\u003cbr\u003e\u003cbr\u003eA tune he composes is made up of several notes. Formally, a $\\bf{tune}$ can be regarded as a string consisting of only lower-case letters. Different letters stands for different notes. A substring of a tune is called $\\bf{phrase}$.\u003cbr\u003e\u003cbr\u003eAt the beginning, J has a tune of length $n$. To create new music, J has three operations:\u003cbr\u003e\u003cbr\u003e- $\\mathtt{1\\ c}$ : Insert a note $c$ at the end of the current tune.\u003cbr\u003e- $\\mathtt{2}$ : Delete the note at the beginning of the current tune.\u003cbr\u003e- $\\mathtt{3\\ t}$ : Query the number of the phrase $t$ appears in the current tune.\u003cbr\u003e\u003cbr\u003eNow, J is busy with his new album and invites you to write music together. Can you help him with it?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer $T\\ (1 \\leq T \\leq 5)$, the number of test cases. For each test case:\u003cbr\u003e\u003cbr\u003eThe first line contains a string $S$ of length $n$ $(1\\le n \\le 10^5)$ indicating the initial tune.\u003cbr\u003e\u003cbr\u003eThe next line contains one integer $m$ $(1\\le m\\le 10^5)$ indicating the number of operations.\u003cbr\u003e\u003cbr\u003eFor the following $m$ lines, the $i$-th line contains an operation like $\\mathtt{1\\ c}$, $\\mathtt{2}$ or $\\mathtt{3\\ t}\u0027$.\u003cbr\u003e\u003cbr\u003eLet\u0027s define the last answer as $lastans$. At the beginning, $lastans \u003d 0$.\u003cbr\u003e\u003cbr\u003e- For $\\mathtt{1\\ c\u0027}$, the real operation is $c \u003d ((c\u0027- \u0027a\u0027) \\oplus lastans)\\bmod 26 + \u0027a\u0027$.\u003cbr\u003e- For $\\mathtt{3\\ t\u0027}$, the real operation is for every $1\\le i\\le |t|,\\ t_i \u003d ((t\u0027_i-\u0027a\u0027) \\oplus lastans)\\bmod 26 + \u0027a\u0027$.\u003cbr\u003e\u003cbr\u003eIt\u0027s guaranteed that $c$ is a lower-case letter. $t$ is a string consisting only of lower-case letters. The sum of the lengths of $t$ of all test cases will not exceed $5 \\times 10^6$.\u003cbr\u003e\u003cbr\u003eNote that string $S$ may be deleted to an empty string. But it\u0027s guaranteed that there will be no operations of type 2 at this time."}},{"title":"Output","value":{"format":"HTML","content":"For each query $\\mathtt{3\\ t}$, print a single integer in a single line indicating the answer."}},{"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\u003e1\r\nabcbaba\r\n5\r\n3 ab\r\n3 c\r\n1 a\r\n2\r\n3 da\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}