{"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\"\u003eJong Hyok喜欢字符串。有一天,他在你面前写下了n个字符串Pi,并提出了m个问题。对于第i个问题,有一个字符串Qi。我们称奇怪的集合(s)\u003d{(i, j) | s出现在Pi中,j是其当前出现的最后一个字符的位置}。对于第i个问题,你必须回答满足奇怪集合(Qi) \u003d 奇怪集合(t)且t是给定的n个字符串中至少一个的子字符串的不同字符串t的数量。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"第一行包含T,表示测试用例的数量。\u003cbr\u003e\u003cbr\u003e对于每个测试用例,有两个数字n,m,然后是n个字符串Pi和m个字符串Qj。(i \u003d 1…n, j \u003d 1…m)\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e1 ≤ T ≤ 10\u003cbr\u003e1 ≤ n ≤ 100000\u003cbr\u003e1 ≤ m ≤ 500000\u003cbr\u003e1 ≤ |Pi| ≤ 100000\u003cbr\u003e1 ≤ |Qi| ≤ 100000\u003cbr\u003e $\\sum_{i\u003d1}^{n} |P_i|\\leq 100000$\u003cbr\u003e文件大小小于3.5兆字节。\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,第一行包含一行“Case #x:”,其中x是案例的编号。\u003cbr\u003e\u003cbr\u003e对于每个问题,你应该在一行中打印一个整数。\u003cbr\u003e"}},{"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\u003e1\r\n2 2\r\naba\r\nab\r\na\r\nab\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n1\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"提示","value":{"format":"HTML","content":"\u003cbr\u003e奇怪集合(“a”) \u003d{(1, 1), (1, 3), (2, 1)}.\u003cbr\u003e奇怪集合(“ab”) \u003d{(1, 2), (2, 2)}.\u003cbr\u003e奇怪集合(“b”) \u003d{(1, 2), (2, 2)}.\u003cbr\u003e"}}]}