#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i <= n; ++i) a[i] = i + 1;
  int ans = 0, temp = n;
  for (int i = 0; i < n; ++i) ans += a[i] * (temp - i);
  int counter = 0;
  int z[n];
  do {
    for (int i = 0; i < n; ++i) z[i] = a[i];
    int shit = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        sort(z + i, z + j + 1);
        shit += z[i];
        for (int f = 0; f < n; ++f) z[f] = a[f];
      }
    }
    if (shit == ans) ++counter;
    if (counter == m) break;
  } while (next_permutation(a, a + n));
  for (int i = 0; i < n; ++i) {
    printf("%d ", a[i]);
  }
  return 0;
}
