#include<stdio.h>
#include<queue>
using namespace std;
int main() {
int i,n,m,j,k,a[1001];
while(scanf("%d%d",&n,&m)!=EOF) {
for(i=1;i<=n;i++)
a[i]=i;
int j=1;
while(j<m) {
next_permutation(a+1,a+n+1);
j++;
}
for(i=1;i<n;i++)
printf("%d ",a[i]);
printf("%d
",a[n]);
}
return 0;
}