Subsets (2) P33748


Statement
 

pdf   zip

Write a program that, given a natural number mm and nn different words s1,,sns_1, \dots, s_n, prints all the subsets of mm elements that can be made up with the words.

Input

Input consists of two natural numbers mm and nn, followed by s1,,sns_1, \dots, s_n. Assume n>0n > 0 and 0mn0 \le m \le n.

Output

Print all the subsets of mm words that can be made up with s1,,sns_1, \dots, s_n.

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