#include <bits/stdc++.h>
using namespace std;
int n, m, a[10], ans[10];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) a[i] = i;
  int minn = 0, cnt = 0;
  do {
    int tmp = 0;
    for (int i = 1; i <= n; i++) {
      int tmpp = 11111;
      for (int j = i; j <= n; j++) {
        tmpp = min(tmpp, a[j]);
        tmp += tmpp;
      }
    }
    if (tmp > minn) minn = tmp, cnt = 0;
    if (tmp == minn) {
      cnt++;
      if (cnt == m)
        for (int i = 1; i <= n; i++) ans[i] = a[i];
    }
  } while (next_permutation(a + 1, a + n + 1));
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}
