{"trustable":false,"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\"\u003e\n Your platoon of wandering lizards has entered a strange room in the labyrinth you are exploring. As you are looking around for hidden treasures, one of the rookies steps on an innocent-looking stone and the room\u0027s floor suddenly disappears! Each lizard in your platoon is left standing on a fragile-looking pillar, and a fire begins to rage below... Leave no lizard behind! Get as many lizards as possible out of the room, and report the number of casualties.\n \u003cbr\u003eThe pillars in the room are aligned as a grid, with each pillar one unit away from the pillars to its east, west, north and south. Pillars at the edge of the grid are one unit away from the edge of the room (safety). Not all pillars necessarily have a lizard. A lizard is able to leap onto any unoccupied pillar that is within d units of his current one. A lizard standing on a pillar within leaping distance of the edge of the room may always leap to safety... but there\u0027s a catch: each pillar becomes weakened after each jump, and will soon collapse and no longer be usable by other lizards. Leaping onto a pillar does not cause it to weaken or collapse; only leaping off of it causes it to weaken and eventually collapse. Only one lizard may be on a pillar at any given time.\n\u003c/div\u003e\n\u003cp\u003e有一些蜥蜴被困在了石柱上,石柱区域是一张 $n\\times m$ 的网格,每根石柱都有一个高度 $h_{i,j}$\u003c/p\u003e\n\u003cp\u003e每只蜥蜴单次跳跃距离最大为 $d$(曼哈顿距离),并且当蜥蜴离开某根石柱后,那根石柱的高度会 $-1$,当高度为 $0$ 时将不能站在上面\u003c/p\u003e\n\u003cp\u003e在同一时间内不能有两只及以上的蜥蜴位于同一根石柱上,如果一只蜥蜴能够在某次跳跃中跳出网格,那么它就能够成功逃脱\u003c/p\u003e\n\u003cp\u003e问最终最少有多少只蜥蜴跳不出这张网格?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input file will begin with a line containing a single integer representing the number of test cases, which is at most 25. Each test case will begin with a line containing a single positive integer n representing the number of rows in the map, followed by a single non-negative integer d representing the maximum leaping distance for the lizards. Two maps will follow, each as a map of characters with one row per line. The first map will contain a digit (0-3) in each position representing the number of jumps the pillar in that position will sustain before collapsing (0 means there is no pillar there). The second map will follow, with an \u0027L\u0027 for every position where a lizard is on the pillar and a \u0027.\u0027 for every empty pillar. There will never be a lizard on a position where there is no pillar.Each input map is guaranteed to be a rectangle of size n x m, where 1 ≤ n ≤ 20 and 1 ≤ m ≤ 20. The leaping distance is\n\u003cbr\u003ealways 1 ≤ d ≤ 3.\n\u003cp\u003e输入第一行包含一个整数 $T$,表示数据组数,$T\\le 25$\u003c/p\u003e\n\u003cp\u003e每组数据第一行包含两整数 $n,d\\ (1\\le n\\le 20, 1\\le d\\le 3)$,表示行数及蜥蜴单次最大跳跃距离\u003c/p\u003e\n\u003cp\u003e其后 $n$ 行,每行固定 $m$ 个字符,表示每个位置的石柱初始高度 $(0\\le h_{i,j}\\le 3)$\u003c/p\u003e\n\u003cp\u003e其后 $n$ 行,每行固定 $m$ 个字符,如果为 L 则表示初始时该位置有一只蜥蜴\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each input case, print a single line containing the number of lizards that could not escape. The format should follow the samples provided below."}},{"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\u003e\u003cpre\u003e4\n3 1\n1111\n1111\n1111\nLLLL\nLLLL\nLLLL\n3 2\n00000\n01110\n00000\n.....\n.LLL.\n.....\n3 1\n00000\n01110\n00000\n.....\n.LLL.\n.....\n5 2\n00000000\n02000000\n00321100\n02000000\n00000000\n........\n........\n..LLLL..\n........\n........\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003eCase #1: 2 lizards were left behind.\nCase #2: no lizard was left behind.\nCase #3: 3 lizards were left behind.\nCase #4: 1 lizard was left behind.\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}