#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int m;
  cin >> m;
  int a[n];
  for (int i = 0; i < n; i++) a[i] = i + 1;
  int ans = 0;
  int min_;
  for (int i = 0; i < n; i++) {
    min_ = a[i];
    for (int j = i; j < n; j++) {
      if (min_ > a[j]) min_ = a[j];
      ans += min_;
    }
  }
  if (m == 1) {
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    return 0;
  }
  m--;
  while (next_permutation(a, a + n)) {
    int temp = 0;
    for (int i = 0; i < n; i++) {
      min_ = a[i];
      for (int j = i; j < n; j++) {
        if (min_ > a[j]) min_ = a[j];
        temp += min_;
      }
    }
    if (temp == ans) m--;
    if (m == 0) {
      for (int i = 0; i < n; i++) cout << a[i] << " ";
      cout << endl;
      break;
    }
  }
  return 0;
}
