{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cbr\u003eYou\u0027ve decided to make a puzzle as a part of the \"re-branding\" campaign run by your company. In the box this puzzle will look as the new logo of your company, that is, it will be a set of 9 (nine) connected unit squares on a rectangular grid. However, these 9 squares will not necessarily all be glued together, i.e., they may form several connected parts (however, you\u0027re not allowed to split squares in the middle). The objective of the puzzle will be to rearrange those parts so that they form a 3x3 square. When rearranging, one is only allowed to shift parts, and NOT to rotate or to flip them.\u003cbr\u003eTo make the puzzle more challenging, you need to have as few parts as possible. Given the logo, compute how many parts do you need and how to rearrange them into a 3x3 square. \u003cbr\u003eEvery word \"connected\" in the problem statement means connectedness in the side-by-side sense.\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003eThe first line of input contains two integers \u003ci\u003eH\u003c/i\u003e and \u003ci\u003eW\u003c/i\u003e. The next \u003ci\u003eH\u003c/i\u003e lines will contain \u003ci\u003eW\u003c/i\u003e characters each, describing your logo. Each of those characters will be either \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003e.\u003c/pre\u003e\u0027 (dot), denoting an empty square, or \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eX\u003c/pre\u003e\u0027 (capital English letter X), denoting a square occupied by the logo. All the \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eX\u003c/pre\u003e\u0027s will form a connected figure, there will be exactly 9 \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eX\u003c/pre\u003e\u0027s in input. The first line, the last line, the first column and the last column will contain at least one \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eX\u003c/pre\u003e\u0027, in other words, there will not be unnecessary empty rows at any side of the grid.\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003eOn the first line, output the required number of parts \u003ci\u003eK\u003c/i\u003e. Afterwards, output one of the possible rearrangements, more precisely: on the next \u003ci\u003eH\u003c/i\u003e lines output the logo with all the \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eX\u003c/pre\u003e\u0027s replaced by the first \u003ci\u003eK\u003c/i\u003e capital letters of English alphabet, each letter denoting one part. Then output an empty line, and then 3 lines containing 3 characters each, containing the same \u003ci\u003eK\u003c/i\u003e parts but shifted around so that they form a 3x3 square.\u003cbr\u003eAll the parts must be connected, and \u003ci\u003eK\u003c/i\u003e must be as little as possible. If there\u0027re several possible solutions, output any.\u003cbr\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\u003e4 5\n....X\n....X\n..XXX\nXXXX.\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n....A\n....C\n..CCC\nBBCC.\n\u0026nbsp;\nBBC\nCCC\nCCA\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}