#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k;
  cin >> n >> m;
  int a[10];
  for (i = 1; i <= n; i++) a[i - 1] = i;
  int max = 0;
  do {
    int c = 0;
    for (i = 0; i < n; i++) {
      for (j = i; j < n; j++) {
        int mn = 100;
        for (k = i; k <= j; k++) {
          if (mn > a[k]) mn = a[k];
        }
        c += mn;
      }
    }
    if (c > max) max = c;
  } while (next_permutation(a, a + n));
  int cnt = 0;
  do {
    int c = 0;
    for (i = 0; i < n; i++) {
      for (j = i; j < n; j++) {
        int mn = 100;
        for (k = i; k <= j; k++) {
          if (mn > a[k]) mn = a[k];
        }
        c += mn;
      }
    }
    if (c == max) {
      cnt++;
      if (cnt == m) break;
    }
  } while (next_permutation(a, a + n));
  printf("%d", a[0]);
  for (i = 1; i < n; i++) printf(" %d", a[i]);
  printf("\n");
  return 0;
}
