#include <bits/stdc++.h>
using namespace std;
vector<string> s;
int n, m;
int vis[200];
void f(string st, int i, int visited[200]) {
  if (i > n) {
    s.push_back(st);
    return;
  }
  for (int r = 1; r <= n; r++) {
    if (!visited[r]) {
      visited[r] = 1;
      string st1 = st;
      st1 += r + '0';
      f(st1, i + 1, visited);
      visited[r] = 0;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  string second;
  f(second, 1, vis);
  int max = -1;
  for (int t = 0; t < s.size(); t++) {
    int ans = 0;
    for (int i = 0; i < s[t].size(); i++) {
      for (int j = i; j < s[t].size(); j++) {
        int min = 999;
        for (int q = i; q <= j; q++)
          if (s[t][q] - '0' < min) min = s[t][q] - '0';
        ans += min;
      }
    }
    if (ans > max) max = ans;
  }
  int co = 0;
  for (int t = 0; t < s.size(); t++) {
    int ans = 0;
    for (int i = 0; i < s[t].size(); i++) {
      for (int j = i; j < s[t].size(); j++) {
        int min = 999;
        for (int q = i; q <= j; q++)
          if (s[t][q] - '0' < min) min = s[t][q] - '0';
        ans += min;
      }
    }
    if (ans == max) {
      co++;
      if (co == m) {
        for (int i = 0; i < s[t].size(); i++) cout << s[t][i] << ' ';
      }
    }
  }
  return 0;
}
