#include <iostream>
#include <cstdlib>

using namespace std;

class conjunto {
    private:
        int bits;

    public:
        conjunto(int co= 0);
        conjunto(int a, int b);
        conjunto& operator += (int k);
        conjunto& operator -= (int k);
        int Bits(void) const;
        ostream&  print(ostream& os)  const;
        int Card(void) const;
};


conjunto::conjunto(int co)
{
    bits= co;
}

conjunto::conjunto(int a, int b)
{
     bits= 0;
     for (int k=a; k<=b; k++)
         bits|= (1<<k);
}




conjunto& conjunto::operator += (int k)
{
    bits|= 1 << k;
    return *this;
}

conjunto& conjunto::operator -= (int k)
{
    bits&= ~(1 << k);
    return *this;
}

int conjunto::Bits(void) const
{
   return bits;
}


ostream& conjunto::print(ostream& os) const
{
    int s= 8*sizeof(bits);
    os << "{";
    for (int k=0; k<s; k++) 
       if ( ((1 << k) & bits) != 0)
          os << ' ' << k;
    os << " }";
    return os;
}

ostream& operator << (ostream& os, 
                      const conjunto& c)
{
   return c.print(os);
}

conjunto operator + (const conjunto& A,
                     const conjunto& B)
{
   return conjunto(A.Bits() | B.Bits()); 
}

conjunto operator * (const conjunto& A,
                     const conjunto& B)
{
   return conjunto(A.Bits() & B.Bits()); 
}

int conjunto::Card(void) const
{
    int s= 8*sizeof(bits);
    int ca= 0;
    for (int k=0; k<s; k++) 
       if ( ((1 << k) & bits) != 0)
          ca++;
    return ca;
}

void TriPas(int n, int k, conjunto A)
{
   if (k==0)
      {
       cout << A << endl;
       return;
      }
   if (k==n)
      {
       cout << A+ conjunto(0,n-1) << endl;
       return;
      }
   TriPas(n-1, k-1, A+=n-1);
   TriPas(n-1, k,   A-=n-1); 
}


int main(int argc, char* argv[])
{
    if (argc < 3)
       {
        cerr << "usage: " << argv[0] << " n k \n";
        return EXIT_FAILURE;
       }
    int n= atoi(argv[1]);
    int k= atoi(argv[2]);
    TriPas(n,k, conjunto() );
    return EXIT_SUCCESS;
}








