#include <bits/stdc++.h>
using namespace std;
int n, m, h, P[10], F[10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) P[i] = i;
  F[0] = 1;
  for (int i = 1; i <= n; i++) F[i] = F[i - 1] * i;
  int l = F[n], maxx = 0;
  while (l--) {
    int s = 0;
    for (int i = 1; i <= n; i++) {
      int minn = 1e9;
      for (int j = i; j <= n; j++) {
        if (P[j] < minn) minn = P[j];
        s += minn;
      }
    }
    if (s > maxx) maxx = s;
    next_permutation(P + 1, P + n + 1);
  }
  l = F[n];
  for (int i = 1; i <= n; i++) P[i] = i;
  while (l--) {
    int s = 0;
    for (int i = 1; i <= n; i++) {
      int minn = 1e9;
      for (int j = i; j <= n; j++) {
        if (P[j] < minn) minn = P[j];
        s += minn;
      }
    }
    if (s == maxx) {
      h++;
      if (h == m) {
        for (int i = 1; i < n; i++) printf("%d ", P[i]);
        printf("%d\n", P[n]);
        break;
      }
    }
    next_permutation(P + 1, P + n + 1);
  }
  return 0;
}
