#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int str[11000];
int main( )
{
int N, M, i, j;
while ( scanf("%d%d", &N, &M) != EOF) {
for ( i = 1; i <= N; i++)
str[i-1] = i; //默认已经是第1小了
int num = 0;
while( num < M - 1 ) {
next_permutation(str, str + N);
num++;
}
printf("%d",str[0]);
for(i = 1; i < N; i++)
printf(" %d",str[i]);
puts("");
}
return 0;
}