#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, count = 0;
  long long f = 0;
  cin >> n >> m;
  vector<int> a;
  int curcount = 0, curmax = 0;
  for (int i = 0; i < n; i++) a.push_back(i + 1);
  do {
    int cur = 0;
    f = 0;
    for (int i = 0; i < n; i++) {
      cur = n + 1;
      for (int j = i; j < n; j++) {
        if (a[j] < cur) cur = a[j];
        f += cur;
      }
    }
    if (f > curmax) {
      curmax = f;
    }
  } while (next_permutation(a.begin(), a.end()));
  do {
    int cur = 0;
    f = 0;
    for (int i = 0; i < n; i++) {
      cur = n + 1;
      for (int j = i; j < n; j++) {
        if (a[j] < cur) cur = a[j];
        f += cur;
      }
    }
    if (f == curmax) {
      curcount++;
    }
    if (curcount == m) break;
  } while (next_permutation(a.begin(), a.end()));
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
