{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eThe LCP (Longest Common Prefix) of two strings A[1..la] and B[1..lb] is defined as follows:\r\n\u003cbr\u003e\u003cbr\u003e\r\nLCP(A[1..la],B[1..lb]) \u003d max{L | L\u0026lt;\u003dla \u0026amp;\u0026amp; L\u0026lt;\u003dlb \u0026amp;\u0026amp; A[1..L] \u003d\u003d B[1..L]}\r\n\u003cbr\u003e\u003cbr\u003e\r\nGiven an original string and several operations, you should write a program to process all the operations.\r\n\r\n\u003c/p\u003e\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line will be number of test cases T.\u003cbr\u003e\r\nThe first line of each test case is a string S with length L (1 \u0026lt;\u003d L \u0026lt;\u003d 100000).\u003cbr\u003e\r\nThe second line contains an integer Q(1 \u0026lt;\u003d Q \u0026lt;\u003d 150000), representing the number of operations.\u003cbr\u003e\u003cbr\u003e\r\nEach of the following Q lines represents an operation:\u003cbr\u003e\r\nQ i j: print LCP(S[i..L], S[j..L])\u003cbr\u003e\r\nR i char: replace the i-th character of S with char\u003cbr\u003e\r\nI i char: insert character char after the i-th character of S\u003cbr\u003e\r\n\r\n\u003c/p\u003e\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each \"Q i j\" operation, print the answer.\r\n\r\n\u003c/p\u003e\u003ch3\u003eExample\u003c/h3\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\nmadamimadam\r\n7\r\nQ 1 7\r\nQ 4 8\r\nQ 10 11\r\nR 3 a\r\nQ 1 7\r\nI 10 a\r\nQ 2 11\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n1\r\n0\r\n2\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\n\u003c/div\u003e"}}]}