#include <bits/stdc++.h>
using namespace std;
int n;
long long m;
void solve1() {
  int mas[50];
  for (int i = 0; i < n; i++) mas[i] = i + 1;
  int maxsum = 0;
  do {
    int cursum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int mini = n;
        for (int k = i; k <= j; k++) mini = min(mini, mas[k]);
        cursum += mini;
      }
    }
    maxsum = max(maxsum, cursum);
  } while (next_permutation(mas, mas + n));
  int cnt = 0;
  do {
    int cursum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int mini = n;
        for (int k = i; k <= j; k++) mini = min(mini, mas[k]);
        cursum += mini;
      }
    }
    if (cursum == maxsum) {
      cnt++;
      if (cnt == m) {
        for (int i = 0; i < n; i++) cout << mas[i] << " ";
        cout << endl;
        return;
      }
    }
  } while (next_permutation(mas, mas + n));
}
int perm[50];
long long calc(int last) {
  int cur = 0;
  bool vozr = false;
  bool used[51];
  for (int i = 1; i <= n; i++) used[i] = false;
  for (int i = 0; i < n; i++) used[perm[i]] = true;
  while (cur < last && perm[cur] < perm[cur + 1]) cur++;
  if (cur == last)
    vozr = true;
  else if (perm[cur] != n)
    return 0;
  while (cur < last && perm[cur] > perm[cur + 1]) cur++;
  if (cur < last) return 0;
  for (int i = perm[last]; i <= n; i++)
    if (!vozr && !used[i]) return 0;
  if (!vozr || (vozr && perm[last] == n)) {
    return 1;
  } else if (vozr) {
    return (1ll << (n - perm[last] - 1));
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) {
      perm[i] = j;
      long long curres = calc(i);
      if (curres >= m)
        break;
      else
        m -= curres;
    }
  }
  for (int i = 0; i < n; i++) cout << perm[i] << " ";
  cout << endl;
  return 0;
}
