#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long ret = 0, f = 1;
  char x = getchar();
  while (!(x >= '0' && x <= '9')) {
    if (x == '-') f = -1;
    x = getchar();
  }
  while (x >= '0' && x <= '9') ret = ret * 10 + x - '0', x = getchar();
  return ret * f;
}
const int L_N = 10;
int MX = 0;
int N, M, cnt;
int q[L_N], use[L_N];
int cal_f() {
  int ret = 0;
  for (int i = (1); i <= (N); i++) {
    int mi = q[i];
    for (int j = (i); j <= (N); j++) {
      mi = min(mi, q[j]);
      ret += mi;
    }
  }
  return ret;
}
void find_max(int p) {
  if (p > N) {
    int t = cal_f();
    MX = max(MX, t);
    return;
  }
  for (int i = (1); i <= (N); i++)
    if (!use[i]) {
      use[i] = true;
      q[p] = i;
      find_max(p + 1);
      q[p] = 0;
      use[i] = false;
    }
}
void find_ans(int p) {
  if (p > N) {
    int t = cal_f();
    if (t == MX) cnt++;
    if (cnt == M) {
      for (int i = (1); i <= (N); i++) printf("%d ", q[i]);
      exit(0);
    }
    return;
  }
  for (int i = (1); i <= (N); i++)
    if (!use[i]) {
      use[i] = true;
      q[p] = i;
      find_ans(p + 1);
      q[p] = 0;
      use[i] = false;
    }
}
int main() {
  N = read(), M = read();
  find_max(1);
  find_ans(1);
  return 0;
}
