#include <bits/stdc++.h>
using namespace std;
vector<int> vec;
int result[50000];
int MIN(int i, int j) {
  int ans = 1e9;
  for (int a = i; a <= j; a++) {
    ans = min(ans, vec[a]);
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (n); i++) vec.push_back(i + 1);
  int limit = 1;
  for (int i = 0; i < (n); i++) limit *= (i + 1);
  int sum, mx = 0, realsum = 0;
  for (int z = 0; z < (limit); z++) {
    for (int i = 0; i < (n); i++) {
      sum = 0;
      for (int j = i; j < n; j++) sum += MIN(i, j);
      ;
      realsum += sum;
    }
    if (realsum > mx) mx = realsum;
    result[z] = realsum;
    realsum = 0;
    next_permutation(vec.begin(), vec.end());
  }
  vector<int> sol;
  for (int i = 0; i < (n); i++) sol.push_back(i + 1);
  int cnt = 0;
  for (int z = 0; z < (limit); z++) {
    if (result[z] == mx) {
      cnt++;
      if (cnt == m) {
        printf("%d", sol[0]);
        for (int i = 1; i < n; i++) printf(" %d", sol[i]);
        printf("\n");
        break;
      }
    }
    next_permutation(sol.begin(), sol.end());
  }
  return 0;
}
