{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $1 \\le N \\le 400$\n*   $1 \\le M \\le 10^6$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$"},{"iden":"sample input 1","content":"3 1"},{"iden":"sample output 1","content":"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)$."},{"iden":"sample input 2","content":"10 5"},{"iden":"sample output 2","content":"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"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}