#include <bits/stdc++.h>
using namespace std;
const int N = 9;
const double eps = 1e-11;
const int inf = (int)2e9;
const int mod = (int)1e9 + 7;
const double pi = 3.1415926535897932384626433832795;
int a[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int ex = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = i;
    ex += i * (n - i + 1);
  }
  int cnt = 0;
  do {
    int cur = 0;
    for (int i = 1; i <= n; i++) {
      int mn = inf;
      for (int j = i; j <= n; j++) {
        mn = min(mn, a[j]);
        cur += mn;
      }
    }
    if (cur == ex) {
      k--;
      if (!k) {
        for (int i = 1; i <= n; i++) {
          printf("%d%c", a[i], " \n"[i == n]);
        }
      }
    }
  } while (next_permutation(a + 1, a + n + 1));
  return 0;
}
