#include <bits/stdc++.h>
using namespace std;
int ans[10], n, book[10], aa[10][10], sum = 0, m = 0, rs[40325][10],
                                      flag[40325][2];
int cmp(const void *aa, const void *bb) {
  int *a = (int *)aa;
  int *b = (int *)bb;
  if (*a != *b)
    return *b - *a;
  else
    return *(a + 1) - *(b + 1);
}
void dfs(int k, int l, int sum) {
  if (k == n) {
    for (int j = 0; j < k; j++) rs[m][j] = ans[j];
    flag[m][0] = sum;
    flag[m][1] = m;
    m++;
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (!book[i]) {
      aa[k + 1][l + 1] = i;
      for (int j = k; j >= 1; j--) {
        if (i < aa[j][l])
          aa[j][l + 1] = i;
        else
          aa[j][l + 1] = aa[j][l];
      }
      for (int j = 1; j <= k + 1; j++) sum += aa[j][l + 1];
      book[i] = 1;
      ans[k] = i;
      dfs(k + 1, l + 1, sum);
      book[i] = 0;
      for (int j = 1; j <= k + 1; j++) sum -= aa[j][l + 1];
    }
  }
}
int main() {
  int p;
  scanf("%d %d", &n, &p);
  dfs(0, 0, 0);
  qsort(flag, m, sizeof(flag[0]), cmp);
  p = flag[p - 1][1];
  for (int j = 0; j < n; j++) printf("%d ", rs[p][j]);
  printf("\n");
  return 0;
}
