#include <bits/stdc++.h>
using namespace std;
void scan(int &x) {
  register int c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
const int M = 1005;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int s = 0;
  for (int i = 1; i <= n; i++) s += i * (n - i + 1);
  int p[n];
  for (int i = 0; i < n; i++) p[i] = i + 1;
  vector<int> ans;
  do {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int mn = p[i];
      for (int j = i; j < n; j++) {
        mn = min(p[j], mn);
        sum += mn;
      }
    }
    if (sum == s) {
      int a = 0;
      for (int i = 0; i < n; i++) a = a * 10 + p[i];
      ans.push_back(a);
    }
  } while (next_permutation(p, p + n) != 0);
  sort(ans.begin(), ans.end());
  int x = ans[m - 1];
  vector<int> xx;
  while (x > 0) {
    xx.push_back(x % 10);
    x /= 10;
  }
  reverse(xx.begin(), xx.end());
  for (int i = 0; i < xx.size(); i++) {
    cout << xx[i] << " ";
  }
  cout << endl;
  return 0;
}
