#include<iostream>
#include<cstdio>
using namespace std;
int n,m,tot;
int ans[1000][11];
int now[11];
void work(int i,int j,int he)
{
int k;
if ((i==m)&&(n-he>=now[i-1]))
{
tot++; now[i]=n-he;
for (i=1;i<=m;++i)
ans[tot][i]=now[i];
return;
}
for (k=j;k<=n-i;++k)
{
now[i]=k;
work(i+1,k,he+k);
now[i]=0;
}
}
int main()
{
int i,j;
freopen("dataa.in","r",stdin);
freopen("dataa.out","w",stdout);
scanf("%d%d",&n,&m);
tot=0; work(1,1,0);
cout<<tot<<endl;
for (i=1;i<=tot;++i)
{
for (j=1;j<=m;++j)
cout<<ans[i][j]<<' ';
cout<<endl;
}
fclose(stdin);
fclose(stdout);
}