#include <bits/stdc++.h>
using namespace std;
int b[20], a[20], m, cnt;
struct st {
  long long s = 0;
  int v;
} ak[100000];
int cmp(const void *a, const void *b) {
  st c = *(st *)a;
  st d = *(st *)b;
  if (c.v != d.v)
    return d.v - c.v;
  else
    return c.s - d.s;
}
void dfs(int deep, int n) {
  if (deep == n) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int minn = 10000000;
        for (int k = i; k <= j; k++) {
          minn = min(minn, b[k]);
        }
        sum += minn;
      }
    }
    ak[cnt].v = sum;
    for (int i = 0; i < n; i++) {
      ak[cnt].s += b[i];
      ak[cnt].s *= 10;
    }
    ak[cnt].s /= 10;
    cnt++;
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      a[i] = 1;
      b[deep] = i;
      dfs(deep + 1, n);
      a[i] = 0;
    }
  }
}
int main() {
  int i, j, maxx, flag, n;
  int res[20];
  while (~scanf("%d %d", &n, &m)) {
    memset(a, 0, sizeof(a));
    cnt = 0;
    dfs(0, n);
    qsort(ak, cnt, sizeof(ak[0]), cmp);
    long long t = ak[m - 1].s;
    for (i = 0; i < cnt; i++) {
      ak[i].s = 0;
    }
    int cnt1 = 0;
    while (t > 0) {
      res[cnt1++] = t % 10;
      t /= 10;
    }
    for (i = cnt1 - 1; i >= 0; i--) {
      printf(i == cnt1 - 1 ? "%d" : " %d", res[i]);
    }
    puts("");
  }
  return 0;
}
