#include <bits/stdc++.h>
using namespace std;
int a[51], brojac, maxsum, cnt = 1;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cnt *= i;
    a[i - 1] = i;
    maxsum += i * (n + 1 - i);
  }
  while (cnt--) {
    int sum = 0, mine;
    for (int i = 0; i < n; i++) {
      mine = a[i];
      for (int j = i; j < n; j++) {
        mine = min(mine, a[j]);
        sum += mine;
      }
    }
    if (sum == maxsum) {
      brojac++;
      if (brojac == m) {
        for (int i = 0; i < n; i++) cout << a[i] << " ";
        return 0;
      }
    }
    next_permutation(a, a + n);
    int p = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == i + 1) p++;
    }
    if (p == n) break;
  }
  return 0;
}
