{"raw_statement":[{"iden":"problem statement","content":"You are given a permutation $A = (A_1, A_2, \\dots, A_N)$ of $(1, 2, \\dots, N)$.  \nFor a pair of integers $(L, R)$ such that $1 \\leq L \\leq R \\leq N$, let $f(L, R)$ be the permutation obtained by reversing the $L$\\-th through $R$\\-th elements of $A$, that is, replacing $A_L, A_{L+1}, \\dots, A_{R-1}, A_R$ with $A_R, A_{R-1}, \\dots, A_{L+1}, A_{L}$ simultaneously.\nThere are $\\frac{N(N + 1)}{2}$ ways to choose $(L, R)$ such that $1 \\leq L \\leq R \\leq N$.  \nIf the permutations $f(L, R)$ for all such pairs $(L, R)$ are listed and sorted in lexicographical order, what is the $K$\\-th permutation from the front?\nWhat is lexicographical order on sequences?A sequence $S = (S_1,S_2,\\ldots,S_{|S|})$ is said to be **lexicographically smaller** than a sequence $T = (T_1,T_2,\\ldots,T_{|T|})$ if and only if 1. or 2. below holds. Here, $|S|$ and $|T|$ denote the lengths of $S$ and $T$, respectively.\n\n1.  $|S| \\lt |T|$ and $(S_1,S_2,\\ldots,S_{|S|}) = (T_1,T_2,\\ldots,T_{|S|})$.\n2.  There is an integer $1 \\leq i \\leq \\min\\lbrace |S|, |T| \\rbrace$ that satisfies both of the following.\n    *   $(S_1,S_2,\\ldots,S_{i-1}) = (T_1,T_2,\\ldots,T_{i-1})$.\n    *   $S_i$ is smaller than $T_i$ (as a number)."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 7000$\n*   $1 \\leq K \\leq \\frac{N(N + 1)}{2}$\n*   $A$ is a permutation of $(1, 2, \\dots, N)$."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\dots$ $A_N$"},{"iden":"sample input 1","content":"3 5\n1 3 2"},{"iden":"sample output 1","content":"2 3 1\n\nHere are the permutations $f(L, R)$ for all pairs $(L, R)$ such that $1 \\leq L \\leq R \\leq N$.\n\n*   $f(1, 1) = (1, 3, 2)$\n*   $f(1, 2) = (3, 1, 2)$\n*   $f(1, 3) = (2, 3, 1)$\n*   $f(2, 2) = (1, 3, 2)$\n*   $f(2, 3) = (1, 2, 3)$\n*   $f(3, 3) = (1, 3, 2)$\n\nWhen these are sorted in lexicographical order, the fifth permutation is $f(1, 3) = (2, 3, 1)$, which should be printed."},{"iden":"sample input 2","content":"5 15\n1 2 3 4 5"},{"iden":"sample output 2","content":"5 4 3 2 1\n\nThe answer is $f(1, 5)$."},{"iden":"sample input 3","content":"10 37\n9 2 1 3 8 7 10 4 5 6"},{"iden":"sample output 3","content":"9 2 1 6 5 4 10 7 8 3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}