{"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\"\u003eDanganronpa is a video game franchise created and developed by Spike Chunsoft, the series\u0027 name is compounded from the Japanese words for \"bullet\" (dangan) and \"refutation\" (ronpa).\u003cbr\u003e\u003cbr\u003eNow, Stilwell is playing this game. There are $n$ verbal evidences, and Stilwell has $m$ \"bullets\". Stilwell will use these bullets to shoot every verbal evidence.\u003cbr\u003e\u003cbr\u003eVerbal evidences will be described as some strings $A_i$, and bullets are some strings $B_j$. The damage to verbal evidence $A_i$ from the bullet $B_j$ is $f(A_i,B_j)$.\u003cbr\u003e$$f(A,B)\u003d\\sum_{i\u003d1}^{|A|-|B|+1}[~A[i...i+|B|-1]\u003dB~]$$In other words, $f(A,B)$ is equal to the times that string $B$ appears as a substring in string $A$.\u003cbr\u003eFor example: $f(ababa,ab)\u003d2$, $f(ccccc,cc)\u003d4$\u003cbr\u003e\u003cbr\u003eStilwell wants to calculate the total damage of each verbal evidence $A_i$ after shooting all $m$ bullets $B_j$, in other words is $\\sum_{j\u003d1}^m f(A_i,B_j)$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains a single number $T$, the number of test cases.\u003cbr\u003eFor each test case, the first line contains two integers $n$, $m$.\u003cbr\u003eNext $n$ lines, each line contains a string $A_i$, describing a verbal evidence.\u003cbr\u003eNext $m$ lines, each line contains a string $B_j$, describing a bullet.\u003cbr\u003e\u003cbr\u003e$T\\leq 10$\u003cbr\u003eFor each test case, $n,m\\leq 10^5$, $1\\leq |A_i|,|B_j|\\leq 10^4$, $\\sum |A_i|\\leq 10^5$, $\\sum |B_j|\\leq 10^5$\u003cbr\u003eFor all test case, $\\sum |A_i|\\leq 6*10^5$, $\\sum |B_j|\\leq 6*10^5$, $A_i$ and $B_j$ consist of only lowercase English letters"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output $n$ lines, each line contains a integer describing the total damage of $A_i$ from all $m$ bullets, $\\sum_{j\u003d1}^m f(A_i,B_j)$."}},{"title":"Sample","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\n5 6\r\norz\r\nsto\r\nkirigiri\r\ndanganronpa\r\nooooo\r\no\r\nkyouko\r\ndangan\r\nronpa\r\nooooo\r\nooooo\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n1\r\n0\r\n3\r\n7\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}