cho.sh
Notes
Loading...

Snail Table

Time limit

2s

Memory limit

128 MB

Problem

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.

923
814
765
2510111213
2492314
2381415
2276516
2120191817

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.

Input

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.

Output

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.