{"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\"\u003eAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M \u0026lt;\u003d 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.\u003cbr\u003e\u003cbr\u003eAngel\u0027s friends want to save Angel. Their task is: approach Angel. We assume that \"approach Angel\" is to get to the position where Angel stays. When there\u0027s a guard in the grid, we must kill him (or her?) to move into the grid. We assume that we moving up, down, right, left takes us 1 unit time, and killing a guard takes 1 unit time, too. And we are strong enough to kill all the guards.\u003cbr\u003e\u003cbr\u003eYou have to calculate the minimal time to approach Angel. (We can move only UP, DOWN, LEFT and RIGHT, to the neighbor grid within bound, of course.)\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line contains two integers stand for N and M.\u003cbr\u003e\u003cbr\u003eThen N lines follows, every line has M characters. \".\" stands for road, \"a\" stands for Angel, and \"r\" stands for each of Angel\u0027s friend. \u003cbr\u003e\u003cbr\u003eProcess to the end of the file.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, your program should output a single integer, standing for the minimal time needed. If such a number does no exist, you should output a line containing \"Poor ANGEL has to stay in the prison all his life.\" \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\u003e7 8\r\n#.#####.\r\n#.a#..r.\r\n#..#x...\r\n..#..#.#\r\n#...##..\r\n.#......\r\n........\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e13\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}