{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eHosssam decided to sneak into Hemose\u0027s room while he is sleeping and change his laptop\u0027s password. He already knows the password, which is a string $$$s$$$ of length $$$n$$$. He also knows that there are $$$k$$$ \u003cspan class\u003d\"tex-font-style-it\"\u003especial\u003c/span\u003e letters of the alphabet: $$$c_1,c_2,\\ldots, c_k$$$.\u003c/p\u003e\u003cp\u003eHosssam made a program that can do the following.\u003c/p\u003e\u003col\u003e \u003cli\u003e The program considers the current password $$$s$$$ of some length $$$m$$$. \u003c/li\u003e\u003cli\u003e Then it finds all positions $$$i$$$ ($$$1\\le i\u0026lt;m$$$) such that $$$s_{i+1}$$$ is one of the $$$k$$$ special letters. \u003c/li\u003e\u003cli\u003e Then it deletes all of those positions from the password $$$s$$$ \u003cspan class\u003d\"tex-font-style-bf\"\u003eeven if $$$s_{i}$$$ is a special character\u003c/span\u003e. If there are no positions to delete, then the program displays an error message which has a very loud sound. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eFor example, suppose the string $$$s$$$ is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabcdef\u003c/span\u003e\" and the special characters are \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\u0027 and \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003ed\u003c/span\u003e\u0027. If he runs the program once, the positions $$$1$$$ and $$$3$$$ will be deleted as they come before special characters, so the password becomes \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebdef\u003c/span\u003e\". If he runs the program again, it deletes position $$$1$$$, and the password becomes \"\u003cspan class\u003d\"tex-font-style-tt\"\u003edef\u003c/span\u003e\". If he is wise, he won\u0027t run it a third time.\u003c/p\u003e\u003cp\u003eHosssam wants to know how many times he can run the program on Hemose\u0027s laptop without waking him up from the sound of the error message. Can you help him?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow.\u003c/p\u003e\u003cp\u003eThe first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^5$$$) — the initial length of the password.\u003c/p\u003e\u003cp\u003eThe next line contains a string $$$s$$$ consisting of $$$n$$$ lowercase English letters — the initial password.\u003c/p\u003e\u003cp\u003eThe next line contains an integer $$$k$$$ ($$$1 \\le k \\le 26$$$), followed by $$$k$$$ distinct lowercase letters $$$c_1,c_2,\\ldots,c_k$$$ — the special letters.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print the maximum number of times Hosssam can run the program without displaying the error message, on a new line.\u003c/p\u003e"}},{"title":"Examples","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\u003e10\n9\niloveslim\n1 s\n7\njoobeel\n2 o e\n7\nbasiozi\n2 s i\n6\nkhater\n1 r\n7\nabobeih\n6 a b e h i o\n5\nzondl\n5 a b c e f\n6\nshoman\n2 a h\n7\nshetwey\n2 h y\n5\nsamez\n1 m\n6\nmouraz\n1 m\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\n2\n3\n5\n1\n0\n3\n5\n2\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, the program can run $$$5$$$ times as follows: $$$\\text{iloveslim} \\to \\text{ilovslim} \\to \\text{iloslim} \\to \\text{ilslim} \\to \\text{islim} \\to \\text{slim}$$$\u003c/p\u003e\u003cp\u003eIn the second test case, the program can run $$$2$$$ times as follows: $$$\\text{joobeel} \\to \\text{oel} \\to \\text{el}$$$\u003c/p\u003e\u003cp\u003eIn the third test case, the program can run $$$3$$$ times as follows: $$$\\text{basiozi} \\to \\text{bioi} \\to \\text{ii} \\to \\text{i}$$$.\u003c/p\u003e\u003cp\u003eIn the fourth test case, the program can run $$$5$$$ times as follows: $$$\\text{khater} \\to \\text{khatr} \\to \\text{khar} \\to \\text{khr} \\to \\text{kr} \\to \\text{r}$$$\u003c/p\u003e\u003cp\u003eIn the fifth test case, the program can run only once as follows: $$$\\text{abobeih} \\to \\text{h}$$$\u003c/p\u003e\u003cp\u003eIn the sixth test case, the program cannot run as none of the characters in the password is a special character.\u003c/p\u003e"}}]}