Time limit
2s
Memory limit
128 MB
You are given an odd natural number N. Fill an N x N table with the natural numbers from 1 through N^2 in a snail pattern as shown below.
| 9 | 2 | 3 |
| 8 | 1 | 4 |
| 7 | 6 | 5 |
| 25 | 10 | 11 | 12 | 13 |
| 24 | 9 | 2 | 3 | 14 |
| 23 | 8 | 1 | 4 | 15 |
| 22 | 7 | 6 | 5 | 16 |
| 21 | 20 | 19 | 18 | 17 |
Write a program that prints this table for the given N. You are also given one natural number not greater than N^2; print the coordinates of that number as well. Coordinates are expressed as the row number counted from the top and the column number counted from the left.
The first line contains an odd natural number N, where 3 <= N <= 999.
The second line contains the natural number whose position must be found. This number is not greater than N^2.
Print the table over the first N lines. Each line must contain N natural numbers separated by one space. You do not need to align the digit widths.
On the next line, print two integers separated by one space: the coordinates of the given natural number.