{"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\"\u003e\u0026nbsp;\u0026nbsp;Sea5 and wzh are playing games.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;There are some guards on an n × m chessboard. Every guard can attack eight cells around him and release shockwave to attack the whole row and column where he stand.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;Sea5 and wzh are at the beginning stage of the game, they have already put some guards on the chess cells. No guards can be attacked by another guard right now. So they all fell asleep.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;An innocent passer-by is on the chessboard. He can move to up, down, left or right from where he stands. The guards won’t attack him unless the passer-by move to where they stand. The innocent man may appear at any point on the chessboard and move to any point.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The innocent passer-by wants to know the average shortest distance of all the ways he can move without attacked by guards.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;Multiple test cases.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The first line is an integer $T (T \\leq 50)$, the number of cases.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;For each case, first line is two integers $n$ and $m (2 \\leq n, m, \\leq 1000)$. \u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;The next $n$ lines contain $m$ symbols indicate the cells of chessboard. ‘G’ indicates a guard and ‘#’ indicates an empty cell.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;One line per case, shortest distance of all the ways the passer-by can move without attacked by guards.\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;Round the answer to four decimals.\u003cbr\u003e"}},{"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\n2 2\r\n##\r\nG#\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0.8889\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003e\u0026nbsp;\u0026nbsp;Ways of distance 0: 3\u003cbr\u003e\u0026nbsp;\u0026nbsp;Ways of distance 1: 4\u003cbr\u003e\u0026nbsp;\u0026nbsp;Ways of distance 2: 2\u003cbr\u003e\u0026nbsp;\u0026nbsp;The answer is (3 * 0 + 1 * 4 + 2 * 2) / (3 + 4 + 2)\u003cbr\u003e"}}]}