{"problem":{"name":"Root M Leaper","description":{"content":"There is a grid with $N \\times N$ squares. We denote by $(i, j)$ the square at the $i$\\-th row from the top and $j$\\-th column from the left. Initially, a piece is placed on $(1, 1)$. You may repeat t","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc272_d"},"statements":[{"statement_type":"Markdown","content":"There is a grid with $N \\times N$ squares. We denote by $(i, j)$ the square at the $i$\\-th row from the top and $j$\\-th column from the left.\nInitially, a piece is placed on $(1, 1)$. You may repeat the following operation any number of times:\n\n*   Let $(i, j)$ be the square the piece is currently on. Move the piece to the square whose distance from $(i, j)$ is exactly $\\sqrt{M}$.\n\nHere, we define the distance between square $(i, j)$ and square $(k, l)$ as $\\sqrt{(i-k)^2+(j-l)^2}$.\nFor all squares $(i, j)$, determine if the piece can reach $(i, j)$. If it can, find the minimum number of operations required to do so.\n\n## Constraints\n\n*   $1 \\le N \\le 400$\n*   $1 \\le M \\le 10^6$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc272_d","tags":[],"sample_group":[["3 1","0 1 2\n1 2 3\n2 3 4\n\nYou can move the piece to four adjacent squares.\nFor example, we can move the piece to $(2,2)$ with two operations as follows.\n\n*   The piece is now on $(1,1)$. The distance between $(1,1)$ and $(1,2)$ is exactly $\\sqrt{1}$, so move the piece to $(1,2)$.\n*   The piece is now on $(1,2)$. The distance between $(1,2)$ and $(2,2)$ is exactly $\\sqrt{1}$, so move the piece to $(2,2)$."],["10 5","0 3 2 3 2 3 4 5 4 5\n3 4 1 2 3 4 3 4 5 6\n2 1 4 3 2 3 4 5 4 5\n3 2 3 2 3 4 3 4 5 6\n2 3 2 3 4 3 4 5 4 5\n3 4 3 4 3 4 5 4 5 6\n4 3 4 3 4 5 4 5 6 5\n5 4 5 4 5 4 5 6 5 6\n4 5 4 5 4 5 6 5 6 7\n5 6 5 6 5 6 5 6 7 6"]],"created_at":"2026-03-03 11:01:14"}}