#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int n, m, a[10];
int sum, t, maxi = -1, cnt = 0, p, tmp;
void f() {
  sum = 0;
  for (int i = 0; i < n; ++i) {
    t = a[i];
    for (int j = i; j < n; ++j) {
      t = min(t, a[j]);
      sum += t;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    a[i] = i + 1;
  }
  f();
  maxi = sum;
  do {
    p++;
    f();
    if (sum > maxi) {
      maxi = sum;
      cnt = 1;
    } else if (sum == maxi) {
      cnt++;
      if (cnt == m) {
        tmp = p;
      }
    }
  } while (next_permutation(a, a + n));
  p = 0;
  do {
    p++;
    if (tmp == p) {
      break;
    }
  } while (next_permutation(a, a + n));
  for (int i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << "\n";
  return 0;
}
