#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, mi, j, k;
  cin >> n >> m;
  vector<long long> f;
  long long c = 0;
  long long a[n];
  for (i = 0; i < n; i++) a[i] = i + 1;
  do {
    f.push_back(0);
    for (i = 0; i < n; i++) {
      for (j = i; j < n; j++) {
        mi = a[i];
        for (k = i; k <= j; k++) {
          mi = min(mi, a[k]);
        }
        f[c] += mi;
      }
    }
    c++;
  } while (next_permutation(a, a + n));
  long long ma = *max_element(f.begin(), f.end());
  long long co = 0;
  for (i = 0; i < c; i++) {
    if (f[i] == ma) {
      co++;
    }
    if (co == m) break;
  }
  i++;
  for (j = 0; j < n; j++) a[j] = j + 1;
  do {
    i--;
    if (i == 0) break;
  } while (next_permutation(a, a + n));
  for (i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
