Unwind the outer ring

Given an m×n matrix, imagine that it is made out of multiple layers of square-shaped rings.

The first-layer ring, or the outer ring, consists of the outer values on the four "edges" of the matrix.

Unwind the ring by storing the values of the outer layer ring in an array, starting from the top-left and going clockwise.

Display this array.




Enter a matrix: