{"trustable":false,"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\nHosssam 决定趁 Hemose 睡觉时溜进他的房间,修改他笔记本电脑的密码。他已经知道密码是长度为 $n$ 的字符串 $s$ 。他还知道字母表中有 $k$ 个特殊字母: $c_1,c_2,\\ldots, c_k$ .\u003c/p\u003e\n\n霍萨姆制作了一个程序,可以实现以下功能。\n\u003c/p\u003e\n1. 程序会考虑长度为 $m$ 的当前密码 $s$ 。\u003c/p\u003e\n2. 然后,程序会找到所有位置 $i$ ( $1\\le i\u0026lt;m$ ),使得 $s_{i+1}$ 是 $k$ 中的一个特殊字母。\u003c/p\u003e\n3. 然后从密码 $s$ 中删除所有这些位置。**即使 $s_{i}$ 是特殊字符**。如果没有要删除的位置,程序会显示一条错误信息,并发出很大的声音。\u003c/p\u003e\n\n例如,假设字符串 $s$ 为 \"abcdef\",特殊字符为 \"b \"和 \"d\"。如果他运行一次程序, $1$ 和 $3$ 的位置将被删除,因为它们位于特殊字符之前,因此密码变成了 \"bdef\"。如果他再次运行程序,程序会删除位置 $1$ ,密码就变成了 \"def\"。如果他聪明的话,就不会再运行第三次了。\u003c/p\u003e\n\nHosssam 想知道他能在 Hemose 的笔记本电脑上运行多少次程序,而不会被错误信息吵醒。你能帮帮他吗?\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":"Sample 1","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"}}]}