Given a square of text representing a spiral of characters, rotate it!
The spiral starts at the center and moves counterclockwise to the outer edge, starting to the left of center:
987
216
345
This translates to the string 123456789
. Rotation is done to the left, so if you rotate it one position, it will be 234567891
. This is represented by:
198
327
456
Input
Input consists of the spiral and the distance to rotate it.
Distance will always be a positive integer or zero, and can be capped at your language's data type limit.
The spiral should be taken as a string, with a line delimiter of your choice (including no delimiter). It will always be a square, not including delimiters, and have an odd side length.
Assume all characters are alphanumeric [A-Za-z0-9].
Output
Output is the rotated spiral. It should be a square on multiple lines (whether printed or returned).
Examples
Input
3
tne
atd
bin
Output
bat
nit
den
Input
18
efilr
naepo
umshf
tootr
butte
Output
rettu
omseb
oofft
trliu
hpean
This is code golf, with score counted in bytes as usual.