#include <bits/stdc++.h>
using namespace std;
vector<bool> isThere;
string t;
vector<string> p;
vector<int> sums;
void tryit(int i, int n);
int sum(int x, int n);
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; ++i) isThere.push_back(false);
  tryit(1, n);
  sort(p.begin(), p.end());
  int max = 0;
  sums.resize(p.size());
  for (int i = 0; i < p.size(); ++i) {
    sums[i] = sum(i, n);
    if (sums[i] > max) max = sums[i];
  }
  int x = 0;
  while (m != 0) {
    if (sums[x] == max) --m;
    ++x;
  }
  --x;
  for (int i = 0; i < p[x].size(); ++i) {
    cout << (int)p[x][i] << " ";
  }
  cout << endl;
  return 0;
}
void tryit(int i, int n) {
  for (int j = 1; j <= n; ++j) {
    if (!isThere[j]) {
      t.push_back(j);
      isThere[j] = true;
      if (t.size() == n) {
        p.push_back(t);
      } else
        tryit(j, n);
      t.pop_back();
      isThere[j] = false;
    }
  }
}
int sum(int x, int n) {
  int s = 0;
  vector<int> t;
  for (int i = 0; i < p[x].length(); ++i) t.push_back(int(p[x][i]));
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      int min = 300000;
      for (int k = i; k <= j; ++k)
        if (t[k] < min) min = t[k];
      s += min;
    }
  }
  return s;
}
