{"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\"\u003eAndrew is a puzzle lover, he is interested in creating interesting puzzles. One day he creates a new puzzle, following are the rules of the game:\u003cbr\u003e\u003cbr\u003eThe game is played on a big chessboard, it has $n$ rows and $m$ columns. The coordination $(i,j)$ ($1 \\le i \\le n$ ,$1 \\le j \\le m$) indicates the square on $i$-th row and $j$-th column.\u003cbr\u003e\u003cbr\u003eThere are two kinds of chesses, black chess and white chess in this game. Some of the chesses are putted on some squares at the initial of the game, and other squares are empty.\u003cbr\u003e\u003cbr\u003eThe player has to put chesses on \u003cb\u003eall\u003c/b\u003e the empty squares. Both black and white chesses are sufficient enough to be putted on all the squares.\u003cbr\u003e\u003cbr\u003eAfter all the squares on chessboard are full of chess. Andrew begins to calculate the score that player gets. The score is calculated using the following algorithm - For every two squares $(x_1, y_1)$ and $(x_2,y_2)$, the player gets $1$ point if the following $3$ conditions are satisifed:\u003cbr\u003e\u003cbr\u003e - There is a black chess on $(x_1, y_1)$.\u003cbr\u003e - And a white chess on $(x_2, y_2)$.\u003cbr\u003e - $|x_1 - x_2|\u003da$ and $|y_1 - y_2| \u003d b$, which $a$ and $b$ are two constants defined by Andrew before the game starts.\u003cbr\u003e\u003cbr\u003eBut Andrew is confused because he doesn\u0027t know what is the highest possiple score in the game. Can you help him find the best way to solve the puzzle?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input contains an integer $T$ indicating the total number of test cases.\u003cbr\u003e\u003cbr\u003eThe first line of each test case has 4 integers $n, m, a, b$, indicating the number of rows, number of columns and two integers decided by Andrew. The $n$ lines that follow describe the puzzle, the $i$-th of these lines is a string with $m$ characters $c_{i,1}, c_{i,2},..., c_{i,m}$, which $c_{i,j}$ indicates the type of chess that putted on $(i,j)$ at the begin of game. Black chesses are represented by uppercase (\u0027B\u0027), white chesses by uppercase (\u0027W\u0027), and empty squares by period (\u0027.\u0027).\u003cbr\u003e\u003cbr\u003e$1 \\le T \\le 1000$\u003cbr\u003e$1 \\le n,m \\le 100$\u003cbr\u003e$1 \\le a \\le n$, $1 \\le b \\le m$\u003cbr\u003eThere are at most $20$ testcases with $n \u0026gt; 30$ or $m \u0026gt; 30$"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, please output an integer in the first line indicating the highest score that player can get. Then following $n$ lines, each line with $m$ characters indicating the chess type on each square to get the higgest score. The output format is same as input format.\u003cbr\u003e\u003cbr\u003eNote that if there are mutiple ways to get the highest score, you should output the one with smallest lexicographical order in ASCII. (\u0027B\u0027 is smaller than \u0027W\u0027)"}},{"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\u003e2\r\n2 2 1 1\r\n..\r\n..\r\n2 2 1 1\r\n.W\r\n.B\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\nBB\r\nWW\r\n2\r\nWW\r\nBB\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}