Spirals

Write a program that prints “spirals” of size n×nn \times n, as it is shown in the examples.

Input

Input consists of a sequence of strictly positive natural numbers, ended with zero.

Output

For each nn, print a spiral of size n×nn \times n. Note that in the bottom row and in the right column there are only ‘X’s. Print an empty line after each spiral.

Observation

A matrix is not needed to solve this problem, but use it for simplicity.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:13:52.987Z

© Jutge.org, 2006–2026.
https://jutge.org