#include <bits/stdc++.h>
using namespace std;
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T sq(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
T _max(T a, T b) {
  return (!(a < b) ? a : b);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
const int INF = 0x7f7f7f7f;
template <class T>
void deb(T e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << "\t" << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << "\t" << e2 << "\t" << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << endl;
}
template <class T>
void deb(vector<T> e) {
  int i;
  for (i = 0; i < (int)e.size(); i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
void deb(vector<T> e, int n) {
  int i;
  for (i = 0; i < n; i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
void deb(vector<basic_string<T> > e) {
  int i, j;
  for (i = 0; i < (int)e.size(); i++) {
    for (j = 0; j < (int)e[i].size(); j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(vector<basic_string<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(vector<vector<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << "\t";
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(T e[100005][100005], int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
}
template <class T>
void deb(T e[], int row) {
  int i;
  for (i = 0; i < row; i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
inline bool isPrime(T n) {
  if (n <= 1) return false;
  for (T i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool IsVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long int Pow(long long int B, long long int P) {
  long long int R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
int BigMod(long long int B, long long int P, long long int M) {
  long long int R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
void binprint(long long int mask, long long int n) {
  long long int i;
  string s = "";
  do {
    s += (mask % 2 + '0');
    mask /= 2;
  } while (mask);
  reverse(s.begin(), s.end());
  s = string(max(n - (int)s.size(), 0LL), '0') + s;
  for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]);
  printf("\n");
}
void ASCII_Chart() {
  int i, j, k;
  printf("ASCII Chart:(30-129)\n");
  for (i = 30; i < 50; i++) {
    for (j = 0; j < 5; j++) {
      k = i + j * 20;
      printf("%3d---> '%c'   ", k, k);
    }
    printf("\n");
  }
}
vector<vector<int> > arrrr;
int main() {
  int i, j, k, u, v, w, x, y, n, m, z, t = 0, tcase, res = 0;
  vector<int> arr;
  while (cin >> n >> m) {
    arr.clear();
    arrrr.clear();
    for (i = 0; i < n; i++) {
      arr.push_back(i + 1);
    }
    int cnt = 1;
    int maxx = 0;
    do {
      int sum = 0;
      int minx = 10;
      for (i = 0; i < (int)arr.size(); i++) {
        minx = arr[i];
        for (k = i; k < (int)arr.size(); k++) {
          minx = min(minx, arr[k]);
          sum += minx;
        }
      }
      maxx = max(maxx, sum);
      cnt++;
    } while (next_permutation(arr.begin(), arr.end()));
    arr.clear();
    for (i = 0; i < n; i++) {
      arr.push_back(i + 1);
    }
    do {
      int sum = 0;
      int minx = 10;
      for (i = 0; i < (int)arr.size(); i++) {
        minx = arr[i];
        for (k = i; k < (int)arr.size(); k++) {
          minx = min(minx, arr[k]);
          sum += minx;
        }
      }
      if (sum == maxx) arrrr.push_back(arr);
    } while (next_permutation(arr.begin(), arr.end()));
    sort(arrrr.begin(), arrrr.end());
    arr = arrrr[m - 1];
    for (i = 0; i < (int)arr.size(); i++) {
      if (i) cout << " ";
      cout << arr[i];
    }
    cout << endl;
  }
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:

<image>

Find the lexicographically m-th permutation of length n in the set of permutations having the maximum possible value of f(p).

Input

The single line of input contains two integers n and m (1 ≤ m ≤ cntn), where cntn is the number of permutations of length n with maximum possible value of f(p).

The problem consists of two subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.

  * In subproblem B1 (3 points), the constraint 1 ≤ n ≤ 8 will hold. 
  * In subproblem B2 (4 points), the constraint 1 ≤ n ≤ 50 will hold. 

Output

Output n number forming the required permutation.

Examples

Input

2 2


Output

2 1 


Input

3 2


Output

1 3 2 

Note

In the first example, both permutations of numbers {1, 2} yield maximum possible f(p) which is equal to 4. Among them, (2, 1) comes second in lexicographical order.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T sq(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
T _max(T a, T b) {
  return (!(a < b) ? a : b);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
const int INF = 0x7f7f7f7f;
template <class T>
void deb(T e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << "\t" << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << "\t" << e2 << "\t" << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << endl;
}
template <class T>
void deb(vector<T> e) {
  int i;
  for (i = 0; i < (int)e.size(); i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
void deb(vector<T> e, int n) {
  int i;
  for (i = 0; i < n; i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
void deb(vector<basic_string<T> > e) {
  int i, j;
  for (i = 0; i < (int)e.size(); i++) {
    for (j = 0; j < (int)e[i].size(); j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(vector<basic_string<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(vector<vector<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << "\t";
    cout << endl;
  }
  cout << endl;
}
template <class T>
void deb(T e[100005][100005], int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
}
template <class T>
void deb(T e[], int row) {
  int i;
  for (i = 0; i < row; i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
inline bool isPrime(T n) {
  if (n <= 1) return false;
  for (T i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool IsVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long int Pow(long long int B, long long int P) {
  long long int R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
int BigMod(long long int B, long long int P, long long int M) {
  long long int R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
void binprint(long long int mask, long long int n) {
  long long int i;
  string s = "";
  do {
    s += (mask % 2 + '0');
    mask /= 2;
  } while (mask);
  reverse(s.begin(), s.end());
  s = string(max(n - (int)s.size(), 0LL), '0') + s;
  for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]);
  printf("\n");
}
void ASCII_Chart() {
  int i, j, k;
  printf("ASCII Chart:(30-129)\n");
  for (i = 30; i < 50; i++) {
    for (j = 0; j < 5; j++) {
      k = i + j * 20;
      printf("%3d---> '%c'   ", k, k);
    }
    printf("\n");
  }
}
vector<vector<int> > arrrr;
int main() {
  int i, j, k, u, v, w, x, y, n, m, z, t = 0, tcase, res = 0;
  vector<int> arr;
  while (cin >> n >> m) {
    arr.clear();
    arrrr.clear();
    for (i = 0; i < n; i++) {
      arr.push_back(i + 1);
    }
    int cnt = 1;
    int maxx = 0;
    do {
      int sum = 0;
      int minx = 10;
      for (i = 0; i < (int)arr.size(); i++) {
        minx = arr[i];
        for (k = i; k < (int)arr.size(); k++) {
          minx = min(minx, arr[k]);
          sum += minx;
        }
      }
      maxx = max(maxx, sum);
      cnt++;
    } while (next_permutation(arr.begin(), arr.end()));
    arr.clear();
    for (i = 0; i < n; i++) {
      arr.push_back(i + 1);
    }
    do {
      int sum = 0;
      int minx = 10;
      for (i = 0; i < (int)arr.size(); i++) {
        minx = arr[i];
        for (k = i; k < (int)arr.size(); k++) {
          minx = min(minx, arr[k]);
          sum += minx;
        }
      }
      if (sum == maxx) arrrr.push_back(arr);
    } while (next_permutation(arr.begin(), arr.end()));
    sort(arrrr.begin(), arrrr.end());
    arr = arrrr[m - 1];
    for (i = 0; i < (int)arr.size(); i++) {
      if (i) cout << " ";
      cout << arr[i];
    }
    cout << endl;
  }
  return 0;
}

```