#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, j, k;
  scanf("%d%d", &n, &m);
  vector<int> A;
  for (i = 0; i < n; i++) A.push_back(i + 1);
  int M = 0;
  do {
    int s = 0;
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n + 1; j++) {
        int s1 = 1000;
        for (k = i; k < j; k++) s1 = min(s1, A[k]);
        s += s1;
      }
    }
    M = max(M, s);
  } while (next_permutation(A.begin(), A.end()));
  do {
    int s = 0;
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n + 1; j++) {
        int s1 = 1000;
        for (k = i; k < j; k++) s1 = min(s1, A[k]);
        s += s1;
      }
    }
    if (s == M) {
      m--;
      if (m == 0) {
        for (i = 0; i < n; i++) printf("%d ", A[i]);
        return 0;
      }
    }
  } while (next_permutation(A.begin(), A.end()));
  printf("%d\n", m);
}
