{"problem":{"name":"LIS ∩ LDS","description":{"content":"Among the elements of a permutation $P=(P_1,\\ldots,P_N)$ of $(1,\\ldots,N)$, those that satisfy the following condition are called good elements: *   The element can be included in both a longest incr","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc206_d"},"statements":[{"statement_type":"Markdown","content":"Among the elements of a permutation $P=(P_1,\\ldots,P_N)$ of $(1,\\ldots,N)$, those that satisfy the following condition are called good elements:\n\n*   The element can be included in both a longest increasing subsequence and a longest decreasing subsequence of $P$.\n\nYou are given integers $N$ and $K$. Determine whether there exists a permutation $P$ of $(1,\\ldots,N)$ such that there are exactly $K$ good elements, and if it exists, find one.\nAnswer for $T$ test cases.\n\n## Constraints\n\n*   All input values are integers\n*   $1 \\leq T \\leq 2\\times 10^5$\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   $0\\leq K \\leq N$\n*   The sum of $N$ over all test cases does not exceed $2\\times 10^5$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$T$\n$\\mathrm{case}_1$\n$\\vdots$\n$\\mathrm{case}_T$\n\nEach test case is given in the following format:\n\n$N$ $K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc206_d","tags":[],"sample_group":[["3\n1 0\n7 2\n2 1","\\-1\n7 4 6 2 3 1 5\n-1\n\nIn the $2$\\-nd test case, $P_4=2$ and $P_5=3$ are good elements.\nIndeed, $(2,3,5)$ is a longest increasing subsequence of $P$. Also, $(7,6,2,1)$ and $(7, 6, 3, 1)$ are longest decreasing subsequences of $P$.\nTherefore, in this sample output, $2$ and $3$ are good elements. The other elements are not good elements, so this output satisfies the condition.\nIn the $1$\\-st and $3$\\-rd test cases, there does not exist a permutation satisfying the condition. Thus, output `-1`."]],"created_at":"2026-03-03 11:01:14"}}