T3. Spiral T
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given integers N and M, your task is to fill a rectangle with N rows and M columns using integers from the range [1, N*M]. The numbers should be arranged in a counterclockwise spiral pattern, starting from the bottom right corner.
Output the numbers row by row, with a space separating the numbers within each row.
Constraints
2 ≤ 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 189
Acceptance rate 46%