T8. Spiral TT
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 left corner (as illustrated in the examples).
Print the numbers row by row, ensuring there is a space between each number within a row.
Constraints
1 ≤ N, M ≤ 100
Input Format
The input consists of a single line containing the integers N and M, separated by a space.
Output Format
Output the numbers from the range [1, N*M] in the specified spiral order.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 176
Acceptance rate 38%