Subsets (2) P33748


Statement
 

pdf   zip

html

Write a program that, given a natural number m and n different words s1, …, sn, prints all the subsets of m elements that can be made up with the words.

Input

Input consists of two natural numbers m and n, followed by s1, …, sn. Assume n > 0 and 0 ≤ mn.

Output

Print all the subsets of m words that can be made up with s1, …, sn.

Information about the checker

You can print in any order both the solutions and the elements inside each solution.

Public test cases
  • Input

    2 5
    hola adeu hi hello bye
    

    Output

    {hello,bye}
    {hi,bye}
    {hi,hello}
    {adeu,bye}
    {adeu,hello}
    {adeu,hi}
    {hola,bye}
    {hola,hello}
    {hola,hi}
    {hola,adeu}
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python Python
    User solutions
    C++ Python