{"problem":{"name":"F. xor-sum","description":{"content":"You are given four integers $n$, $m$, $s$, $x$. You should construct an array of size $n$, such that:  1)All elements are integers between 0 and $m$. 2)The sum of the array should be $s$. 3)The xo","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10241F"},"statements":[{"statement_type":"Markdown","content":"You are given four integers $n$, $m$, $s$, $x$.\n\nYou should construct an array of size $n$, such that: \n\n1)All elements are integers between 0 and $m$.\n\n2)The sum of the array should be $s$.\n\n3)The xor sum of the array should be $x$.\n\nCan you?\n\nThe first line of input contains one integer $t$ $(1 <= t <= 10^5)$ which is the number of test cases.\n\nFor each test case, the input will contain four integers $n$, $m$, $s$, $x$ $(1 <= n <= 10^5)$ $(0 <= m < 2^(30))$ $(0 <= s <= 10^(18))$ $(0 <= x < 2^(30))$.\n\nThe sum of $n$ overall test cases will not exceed $3 times 10^5$.\n\nFor each test case, if there were no way to construct the array, print $-1$; otherwise, print an array of size $n$ that satisfies the rules on a line.\n\n## Input\n\nThe first line of input contains one integer $t$ $(1 <= t <= 10^5)$ which is the number of test cases.For each test case, the input will contain four integers $n$, $m$, $s$, $x$ $(1 <= n <= 10^5)$ $(0 <= m < 2^(30))$ $(0 <= s <= 10^(18))$ $(0 <= x < 2^(30))$.The sum of $n$ overall test cases will not exceed $3 times 10^5$.\n\n## Output\n\nFor each test case, if there were no way to construct the array, print $-1$; otherwise, print an array of size $n$ that satisfies the rules on a line.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ t \\in \\mathbb{Z}^+ $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, t\\} $, given:  \n- $ n_k \\in \\mathbb{Z}^+ $: length of array  \n- $ m_k \\in \\mathbb{Z}_{\\ge 0} $: upper bound on each element  \n- $ s_k \\in \\mathbb{Z}_{\\ge 0} $: required sum of array  \n- $ x_k \\in \\mathbb{Z}_{\\ge 0} $: required XOR sum of array  \n\n**Constraints**  \n1. $ 1 \\le t \\le 10^5 $  \n2. For each $ k $:  \n   - $ 1 \\le n_k \\le 10^5 $  \n   - $ 0 \\le m_k < 2^{30} $  \n   - $ 0 \\le s_k \\le 10^{18} $  \n   - $ 0 \\le x_k < 2^{30} $  \n3. $ \\sum_{k=1}^t n_k \\le 3 \\times 10^5 $  \n\n**Objective**  \nFor each test case $ k $, determine if there exists an array $ A_k = (a_{k,1}, \\dots, a_{k,n_k}) $ such that:  \n- $ a_{k,i} \\in \\mathbb{Z} $ and $ 0 \\le a_{k,i} \\le m_k $ for all $ i \\in \\{1, \\dots, n_k\\} $  \n- $ \\sum_{i=1}^{n_k} a_{k,i} = s_k $  \n- $ \\bigoplus_{i=1}^{n_k} a_{k,i} = x_k $  \n\nIf such an array exists, output one such array; otherwise, output $-1$.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10241F","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}