#include <bits/stdc++.h>
using namespace std;
int st[50 + 1];
bool mark[50 + 1];
int n, m, max_sum;
int sum() {
  int rez = 0;
  for (int i = 0; i < n; ++i) {
    int min = n + 1;
    for (int j = i; j < n; ++j) {
      if (st[j] < min) min = st[j];
      rez += min;
    }
  }
  return rez;
}
void print() {
  for (int i = 0; i < n; ++i) cout << st[i] << " ";
}
void bkt(int niv) {
  if (!m) return;
  if (niv == n) {
    if (sum() == max_sum) {
      --m;
      if (!m) print();
    }
    return;
  }
  for (int i = 1; i <= n; ++i)
    if (!mark[i]) {
      mark[i] = true;
      st[niv] = i;
      bkt(niv + 1);
      mark[i] = false;
    }
}
int main() {
  cin >> n >> m;
  max_sum = 0;
  for (int i = 1; i <= n; ++i) max_sum += (i * (n - i + 1));
  bkt(0);
  return 0;
}
