#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> ans;
  int tbl[100];
  int n;
  long long m;
  cin >> n >> m;
  tbl[0] = 1;
  m--;
  for (int i = 2; i <= n; ++i) {
    int idx = 0;
    vector<int> row;
    for (int j = 0; j < i - 1; ++j) {
      row.push_back(tbl[j]);
      if (tbl[j] == i - 1) {
        row.push_back(i);
        idx = j;
      }
    }
    if (m >> (n - i) & 1) swap(row[idx], row[idx + 1]);
    for (int j = 0; j < i; ++j) tbl[j] = row[j];
  }
  for (int i = 0; i < n; ++i) cout << tbl[i] << " ";
  cout << endl;
  return 0;
}
