Partitions

Write a program that, given nn different words s1,,sns_1, \dots, s_n and a number pp, prints all the ways to share the words between pp subsets.

Input

Input consists of a natural number n>0n > 0, followed by s1,,sns_1, \dots, s_n, followed by a natural number p>0p > 0.

Output

Print all the ways to share the words between pp subsets. The elements of each set must appear in the same order than in the input. Print an empty line after each partition.

Observation

Strictly speaking, a partition cannot have empty subsets, but we forget about that restriction in this exercise.

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-25T11:35:51.010Z

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