#include <bits/stdc++.h>
using namespace std;
int N, M, step, i, f, found;
int p[18], ma[18];
bool good() {
  int cost = 0;
  for (int i = 1; i <= N; ++i) {
    int m = p[i];
    for (int j = i; j <= N; ++j) {
      m = min(m, p[j]);
      cost += m;
    }
  }
  return (cost == f);
}
void back(int k) {
  if (found) return;
  if (k > N) {
    if (!good()) return;
    ++step;
    if (step == M) {
      for (int i = 1; i <= N; ++i) printf("%d ", p[i]);
      found = true;
      return;
    }
  }
  for (int i = 1; i <= N; ++i)
    if (!ma[i]) {
      p[k] = i;
      ma[i] = true;
      back(k + 1);
      ma[i] = false;
    }
}
int main() {
  scanf("%d%d", &N, &M);
  for (i = 1; i <= N; ++i) f += i * (N - i + 1);
  back(1);
  return 0;
}
