#C14977. Spiral Matrix Generation

    ID: 44685 Type: Default 1000ms 256MiB

Spiral Matrix Generation

Spiral Matrix Generation

Given two integers m and n, generate an \( m \times n \) matrix filled with elements from 1 to \( m \times n \) in spiral order. The spiral starts from the top-left corner and proceeds in a clockwise direction. This problem requires simulating the spiral traversal by adjusting the boundaries as you fill in the matrix.

inputFormat

The input consists of two space-separated integers: m (number of rows) and n (number of columns).

outputFormat

Output the resulting spiral matrix. Each row of the matrix should be printed on a new line with its elements separated by a single space.

## sample
3 3
1 2 3

8 9 4 7 6 5

</p>