Problem Description

Read r and c and a matrix. Output elements in spiral order.

Input Format

First line r c. Next r lines c ints.

Output Format

One line spiral order.

Sample Test Case

Input:
3 3 1 2 3 4 5 6 7 8 9
Output:
1 2 3 6 9 8 7 4 5

Constraints

r*c

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next