#include <bits/stdc++.h>
using namespace std;
int a[50], b[50];
int n;
long long m;
void resetA() {
  for (int i = 0; i < 50; i++) {
    a[i] = 0;
  }
}
void kirito(int count, int op, int ed) {
  if (count == n) {
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << "\n";
    return;
  }
  if (b[count]) {
    a[ed] = count + 1;
    kirito(count + 1, op, ed - 1);
  } else {
    a[op] = count + 1;
    kirito(count + 1, op + 1, ed);
  }
}
int main() {
  while (cin >> n >> m) {
    m--;
    for (int i = n - 2; i >= 0; i--) {
      b[i] = m % 2;
      m /= 2;
    }
    b[n - 1] = 0;
    resetA();
    kirito(0, 0, n - 1);
  }
}
