{"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Pass a year learning in Xi\u0027an, Captain Yang arrival hometown Ningbo at finally. Leave Ningbo one year, Captain Yang have many people to meet. Especially a good friend Mob. \n \u003cbr\u003eCaptain Yang‘s home is at the countryside(城乡结合部), but Mob’s home is in the center of city(市中心). So Yang made arrangements with Mob to meet at a KFC. \n\u003cbr\u003e\u003cbr\u003eThere are many KFC in Ningbo, they want to choose one that let the total time to it be most smallest. (最少)\n \u003cbr\u003e\u003cbr\u003eNow give you a Ningbo map, Both Yang and Mob can move up, down ,left, right to the adjacent road by cost 11 minutes. \n \u003cbr\u003e \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains multiple test cases. \n\u003cbr\u003eEach test case include, first two integers n, m. (2\u0026lt;\u003dn,m\u0026lt;\u003d200). \n\u003cbr\u003eNext n lines, each line included m character. \n\u003cbr\u003e‘Y’ \u0026nbsp;express Yang\u0027s initial position. (杨队的起始位置)\n\u003cbr\u003e‘M’ \u0026nbsp; express Mob\u0027s initial position. (Mob的起始位置)\n\u003cbr\u003e‘#’ forbid road; (走不通)\n\u003cbr\u003e‘.’ Road. (路)\n\u003cbr\u003e‘@’ KCF (肯塔基)\n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case output the minimum total time that both Yang and Mob to arrival one of KFC.You may sure there is always have a KFC that can let them meet."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e4 4\nY.#@\n....\n.#..\n@..M\n4 4\nY.#@\n....\n.#..\n@#.M\n5 5\nY..@.\n.#...\n.#...\n@..M.\n#...#\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e66\n88\n66\u003c/pre\u003e"}}]}