#include <bits/stdc++.h>
using namespace std;
int a[51], book[51], n, m, cnt;
int Max;
int min(int s, int e) {
  int res = a[s];
  for (int i = s; i <= e; i++) {
    if (a[i] < res) {
      res = a[i];
    }
  }
  return res;
}
int fp(int n) {
  int sum = 0, minimum;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      minimum = min(i, j);
      sum += minimum;
    }
  }
  return sum;
}
void dfs(int step) {
  int i;
  if (step == n + 1) {
    int temp = fp(n);
    if (temp == Max) {
      cnt++;
      if (cnt == m) {
        for (i = 1; i <= n; i++) {
          if (i == n)
            cout << a[i];
          else
            cout << a[i] << ' ';
        }
      }
    }
    return;
  }
  for (i = 1; i <= n; i++) {
    if (book[i] == 0) {
      a[step] = i;
      book[i] = 1;
      dfs(step + 1);
      book[i] = 0;
    }
  }
}
int main() {
  int c;
  cin >> n >> m;
  c = n;
  for (int i = 1; i <= n; i++) {
    a[i] = c;
    c--;
  }
  Max = fp(n);
  dfs(1);
  return 0;
}
