#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20000;
int n, m;
int cnt, fnd, ans, used[100], a[100];
vector<int> vec[MAXN];
void check() {
  int now = 0;
  ++cnt;
  for (int i = 1; i <= n; i++) {
    int minx = n + 1;
    for (int j = i; j <= n; j++) {
      minx = min(minx, a[j]);
      now += minx;
    }
  }
  vec[now].push_back(cnt);
  if (now > ans) ans = now;
}
void dfs(int dep) {
  if (dep > n) {
    check();
    return;
  } else {
    for (int i = 1; i <= n; i++) {
      if (!used[i]) {
        used[i] = 1;
        a[dep] = i;
        dfs(dep + 1);
        used[i] = 0;
      }
    }
  }
}
void getans(int dep, int mm) {
  if (dep > n) {
    ++cnt;
    if (cnt == mm) {
      for (int i = 1; i < n; i++) printf("%d ", a[i]);
      printf("%d\n", a[n]);
      fnd = 1;
      return;
    }
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      used[i] = 1;
      a[dep] = i;
      getans(dep + 1, mm);
      used[i] = 0;
      if (fnd) return;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  dfs(1);
  int ansnum = vec[ans][m - 1];
  cnt = 0;
  fnd = 0;
  for (int i = 1; i <= n; i++) used[i] = 0;
  getans(1, ansnum);
  return 0;
}
