Latin square

Write a program that prints all the latin squares n×nn \times n with the first row in increasing order. A latin square must contain all the nummbers between 0 and n1n - 1 in each row and column.

Input

Input consists of a natural number 1n51 \le n \le 5.

Output

Your program must print all the latin squares n×nn \times n with the first row in increasing order. It must print a line in white after each combination.

Information about the checker

You can print the solutions to this exercise in any order.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:22:23.431Z

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