{"problem":{"name":"Sum Avoidance","description":{"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. *   $1\\leq A","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc057_d"},"statements":[{"statement_type":"Markdown","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.\n\n## Constraints\n\n*   $1\\leq T\\leq 1000$\n*   $3\\leq S\\leq 10^{18}$\n*   $1\\leq K \\leq S - 1$\n\n## Input\n\nInput 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc057_d","tags":[],"sample_group":[["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","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)$."]],"created_at":"2026-03-03 11:01:14"}}