import java.util.*;
public class Main {
static int ans = 0;
private static int[] factorial;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int[] arr = new int[n];
for (int i = 1; i <= n; i++) {
arr[i - 1] = i;
}
Factoroal(n);
Deque<Integer> path = new ArrayDeque<>();
boolean[] used = new boolean[n+1];
dfs(n, m, arr, 0, path, used);
for (int c:
path) {
System.out.print(c+" ");
}
}
public static void dfs(int n, int m, int[] arr, int depth, Deque<Integer> path, boolean[] used) {
if (depth == n) {
return;
}
int cnt = factorial[n - 1 - depth];
for (int i = 0; i < n; i++) {
if (used[i]) {
continue;
}
if (cnt < m){
m-=cnt;
continue;
}
path.addLast(arr[i]);
used[i] = true;
dfs(n, m, arr, depth + 1, path, used);
}
}
public static void Factoroal(int n) {
factorial = new int[n + 1];
factorial[0] = 1;
for (int i = 1; i <= n; i++) {
factorial[i] = factorial[i - 1] * i;
}
}
}