{"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维克多喜欢玩字符串。他觉得一个字符串很迷人,尤其是当这个字符串是一个回文字符串的时候。\u003cbr\u003e\u003cbr\u003e维克多想玩$n$次。每次他会做以下四种操作中的一种。\u003cbr\u003e\u003cbr\u003e操作1:在字符串的开头添加一个字符$c$。\u003cbr\u003e\u003cbr\u003e操作2:在字符串的末尾添加一个字符$c$。\u003cbr\u003e\u003cbr\u003e操作3:询问不同迷人子字符串的数量。\u003cbr\u003e\u003cbr\u003e操作4:询问迷人子字符串的数量,同一个子字符串在不同位置开始的情况也要计算在内。\u003cbr\u003e\u003cbr\u003e一开始,维克多有一个空字符串。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"输入包含多个测试用例,最多$5$个。\u003cbr\u003e\u003cbr\u003e在每个测试用例中,第一行包含一个整数$n$,表示操作的次数。\u003cbr\u003e\u003cbr\u003e接下来的$n$行中,第一个数字是整数$op$,表示操作的类型。如果$op$\u003d$1$或$2$,后面会跟着一个小写英文字母。\u003cbr\u003e\u003cbr\u003e$1\\leq n \\leq 100000$。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个查询操作(操作3或4),输出正确的答案。"}},{"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\u003e6\r\n1 a\r\n1 b\r\n2 a\r\n2 c\r\n3\r\n4\r\n8\r\n1 a\r\n2 a\r\n2 a\r\n1 a\r\n3\r\n1 b\r\n3\r\n4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n5\r\n4\r\n5\r\n11\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}