Partitions

Write a program that, given n different words s₁, …, s_(n) and a
number p, prints all the ways to share the words between p subsets.

Input

Input consists of a natural number n > 0, followed by s₁, …, s_(n),
followed by a natural number p > 0.

Output

Print all the ways to share the words between p 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
