#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 1; i <= n; i++) v.push_back(i);
  int mx = 0;
  int c = 0;
  do {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int mn = v[i];
        for (int k = i; k <= j; k++) {
          mn = min(mn, v[k]);
        }
        sum += mn;
      }
    }
    mx = max(mx, sum);
  } while (next_permutation((v).begin(), (v).end()));
  sort((v).begin(), (v).end());
  do {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int mn = v[i];
        for (int k = i; k <= j; k++) {
          mn = min(mn, v[k]);
        }
        sum += mn;
      }
    }
    if (sum == mx) c++;
  } while (c < m && next_permutation((v).begin(), (v).end()));
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}
