{"raw_statement":[{"iden":"problem statement","content":"You are given positive integers $S$ and $K$. A sequence of positive integers $A = (A_1, A_2, \\ldots, A_N)$ is said to be a **good sequence** when satisfying the following two conditions.\n\n*   $1\\leq A_1 < A_2 < \\cdots < A_N \\leq S - 1$ holds.\n*   $\\sum_{i=1}^NA_ix_i\\neq S$ holds for any sequence of non-negative integers $(x_1, x_2, \\ldots, x_N)$.\n\nLet $A = (A_1, A_2, \\ldots, A_N)$ be the lexicographically smallest of the good sequences with the maximum number $N$ of terms. Print the $K$\\-th term $A_K$ of this sequence, or `-1` if $K > N$.\nWe will give you $T$ test cases; solve each of them."},{"iden":"constraints","content":"*   $1\\leq T\\leq 1000$\n*   $3\\leq S\\leq 10^{18}$\n*   $1\\leq K \\leq S - 1$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$T$\n$\\text{case}_1$\n$\\vdots$\n$\\text{case}_T$\n\nEach case is in the following format:\n\n$S$ $K$"},{"iden":"sample input 1","content":"13\n3 1\n3 2\n7 1\n7 2\n7 3\n7 4\n10 1\n10 2\n10 3\n10 4\n10 5\n2022 507\n1000000000000000000 999999999999999999"},{"iden":"sample output 1","content":"2\n-1\n2\n4\n6\n-1\n3\n6\n8\n9\n-1\n1351\n-1\n\nFor the cases $S = 3, 7, 10$, the sequence $A$ will be as follows.\n\n*   For $S=3$: $A = (2)$.\n*   For $S=7$: $A = (2,4,6)$.\n*   For $S=10$: $A = (3,6,8,9)$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}