#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int r, i;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int power(long long int x, long long int y) {
  long long int temp, ty, my;
  long long int mod;
  mod = 1000000007;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  ty = (temp % mod) * (temp % mod);
  if (y % 2 == 0) {
    return ty % mod;
  } else {
    my = (x % mod) * (ty % mod);
    return my % mod;
  }
}
int pa[100];
int main() {
  int i, j, n, m, k, p, r;
  cin >> n >> m;
  for (i = (0); i < (n); i++) {
    pa[i] = i + 1;
  }
  int ma = 0;
  do {
    int temp = 0;
    for (i = (0); i < (n); i++) {
      int pre = 100000;
      for (j = (i); j < (n); j++) {
        int minii = 100000;
        int tt = pa[j];
        if (tt < pre) {
          minii = tt;
        } else {
          minii = pre;
        }
        temp = temp + minii;
        pre = minii;
      }
    }
    if (temp > ma) ma = temp;
  } while (next_permutation(pa, pa + n));
  int cn = 0;
  do {
    int temp = 0;
    for (i = (0); i < (n); i++) {
      int pre = 100000;
      for (j = (i); j < (n); j++) {
        int minii = 100000;
        int tt = pa[j];
        if (tt < pre) {
          minii = tt;
        } else {
          minii = pre;
        }
        temp = temp + minii;
        pre = minii;
      }
    }
    if (temp == ma) {
      cn++;
    }
    if (cn == m) break;
  } while (next_permutation(pa, pa + n));
  for (i = (0); i < (n); i++) cout << pa[i] << " ";
  cout << "\n";
  return 0;
}
