{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"There is a square wall which is made of n*n small square bricks. Some bricks are white while some bricks are yellow. Bob is a painter and he wants to paint all the bricks yellow. But there is something wrong with Bob\u0027s brush. Once he uses this brush to paint brick (i, j), the bricks at (i, j), (i-1, j), (i+1, j), (i, j-1) and (i, j+1) all change their color. Your task is to find the minimum number of bricks Bob should paint in order to make all the bricks yellow.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/7d20b479261eb8fa1c1f3f948676182f?v\u003d1716008518\"\u003e\u003c/center\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer t (1 \u0026lt;\u003d t \u0026lt;\u003d 20) that indicates the number of test cases. Then follow the t cases. Each test case begins with a line contains an integer n (1 \u0026lt;\u003d n \u0026lt;\u003d 15), representing the size of wall. The next n lines represent the original wall. Each line contains n characters. The j-th character of the i-th line figures out the color of brick at position (i, j). We use a \u0027w\u0027 to express a white brick while a \u0027y\u0027 to express a yellow brick."}},{"title":"Output","value":{"format":"HTML","content":"For each case, output a line contains the minimum number of bricks Bob should paint. If Bob can\u0027t paint all the bricks yellow, print \u0027inf\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\n3\r\nyyy\r\nyyy\r\nyyy\r\n5\r\nwwwww\r\nwwwww\r\nwwwww\r\nwwwww\r\nwwwww\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n15\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}