#include <bits/stdc++.h>
using namespace std;
int k, n, m, a[1000000][10], p[10], f[100000];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) p[i] = i;
  do {
    for (int i = 1; i <= n; ++i) {
      for (int j = i; j <= n; ++j) {
        int mn = p[j];
        for (int q = i; q <= j; ++q)
          if (p[q] < mn) mn = p[q];
        f[k] += mn;
      }
    }
    for (int i = 1; i <= n; ++i) {
      a[k][i] = p[i];
    }
    k++;
  } while (next_permutation(p + 1, p + n + 1));
  int mx = f[0];
  for (int i = 0; i < k; ++i) {
    if (f[i] > mx) mx = f[i];
  }
  int cnt = 0;
  for (int i = 0; i < k; ++i) {
    if (f[i] == mx) cnt++;
    if (cnt == m) {
      for (int j = 1; j <= n; ++j) printf("%d ", a[i][j]);
      return 0;
    }
  }
  return 0;
}
