#include <bits/stdc++.h>
using namespace std;
int per[50000][10], p[10], n, m, cnt, pos, minn;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) p[i] = i;
  do {
    cnt = 0;
    pos++;
    for (int i = 1; i <= n; i++) {
      minn = p[i];
      cnt += minn;
      for (int j = i + 1; j <= n; j++) {
        minn = min(minn, p[j]);
        cnt += minn;
      }
    }
    per[pos][0] = cnt;
    for (int i = 1; i <= n; i++) per[pos][i] = p[i];
  } while (next_permutation(p + 1, p + n + 1));
  int maxx = 0;
  for (int i = 1; i <= pos; i++) maxx = max(maxx, per[i][0]);
  for (int i = 1; i <= pos; i++) {
    if (per[i][0] == maxx && m == 1) {
      for (int j = 1; j <= n; j++) cout << per[i][j] << " ";
      break;
    } else if (per[i][0] == maxx)
      m--;
  }
  return 0;
}
