using?namespace?std;
void?Swap(int?*a,int?*b)?{
int?t;?
t?=?*a;?
*a?=?*b;?
*b?=?t;?
}?
void?Print(int?*a,int?n)?{?
for(int?i?=?0;i?<?n;++i)?printf("%d",a[i]);?
printf("\n");?
}?
void?Permut(int?*a,int?p,int?q,int?length)?{
for(int?i?=?p;i?<=?q;++i)?{?
Swap(&a[i],&a[p]);?
if(p?==?q)?Print(a,length);?
Permut(a,p?+?1,q,length);?
}?
}?
int?main(void)?{
int?n,k,i;
cout?<<?"Input?N,K:";
cin?>>?n?>>?k;
int?*a?=?new?int[n];
for(i?=?0;?i?<?n;?++i)
a[i]?=?i?+?1;
Permut(a,0,n?-?1,k);?
system("pause");
return?0;
}