#include <bits/stdc++.h>
using namespace std;
const long long int maxN = 1E6 + 10;
const long long int mod = 1E9 + 7;
long long int p[50], a[50], n, m;
long long int check() {
  long long int ans = 0;
  for (long long int i = 0; i < n; ++i) {
    long long int mn = p[i];
    for (long long int j = i; j < n; ++j) {
      mn = min(mn, p[j]);
      ans += mn;
    }
  }
  return ans;
}
int32_t main() {
  cin >> n >> m;
  for (long long int i = 0; i < n; ++i) p[i] = i + 1;
  long long int mx = 0, cnt = 0;
  for (long long int i = 0; i < n; ++i) mx += (n - i) * (i + 1);
  do {
    long long int tmp = check();
    if (tmp == mx) cnt++;
    if (cnt == m && tmp == mx)
      for (long long int i = 0; i < n; ++i) a[i] = p[i];
  } while (next_permutation(p, p + n));
  for (long long int i = 0; i < n; ++i) cout << a[i] << ' ';
  cout << "\n";
  return 0;
}
