T9. Spiral TTT
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given integers N and M, fill a rectangle with N rows and M columns using integers from the range [1; N*M]. The numbers should be arranged in a clockwise spiral pattern, starting from the top right corner.
Output the numbers row by row, with a space separating each number within a row.
Constraints
1 ≤ N, M ≤ 100
Input Format
A single line containing the integers N and M, separated by a space.
Output Format
Print the numbers from the range [1; N*M] in the specified spiral order.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 150
Acceptance rate 37%