{"raw_statement":[{"iden":"statement","content":"Ayu is participating in ABC 2018 (Arranging Blocks Competition). In this competition, each contestant is given $M$ minutes and $N$ tasks which should be solved one-by-one in the given order. The contestant who solves the most tasks is the winner. What makes this contest interesting to you (ICPC contestants) is that this contest uses a similar encouragement as ICPC, i.e. balloons. In particular, each time a contestant solves a task, s/he will be given a balloon.\n\nAyu is convinced that she can defeat all other contestants, except one particular contestant, Budi, her rival. Ayu knows well her skill, i.e. she knows exactly how long it takes for her to solve a particular task. Unsurprisingly, Ayu also knows well Budi's skill (they are rival for a reason). Let there be two arrays of integers $A_{1.. N}$ and $B_{1.. N}$. $A_i$ denotes the time (in minutes) needed by Ayu to solve the $i^(t h)$ task, while $B_i$ denotes the time (in minutes) needed by Budi to solve the same $i^(t h)$ task.\n\nHere comes the interesting part. Ayu knows that Budi is very sensitive to any disturbingly loud sound like a balloon being popped. Whenever Budi is surprised (due to a balloon being popped), he will lose his concentration and has to repeat the task he's doing. For example, suppose Budi needs $10$ minutes to solve a particular task. If a balloon pops at the $7^(t h)$ minute, then Budi repeats the task at the $7^(t h)$ minute (out of his $10$ minutes), causing him to solve the task with $7 + 10 = 17$ minutes. If two balloon pops, each at the $7^(t h)$ and $13^(t h)$ minute, then Budi repeats the task at minute $7^(t h)$ (out of his $10$ minutes), repeats it again at minute $6^(t h)$ (out of his $10$ minutes), and finally solved the task with $7 + 6 + 10 = 23$ minutes. If a balloon pops at the same time Budi supposed to solve the task (i.e. at the $10^(t h)$ minute in this example), then Budi will also not solve that task. Therefore, Budi has to spend another $10$ minutes (for a total of $10 + 10 = 20$ minutes) to solve that particular task in this case.\n\nAyu plans to exploit Budi's weakness in order to defeat him, i.e. Ayu will strategically use the balloons (popping them at integer minutes) she gets from solving the tasks. Your task in this problem is to find out whether it is possible for Ayu to have the number of solved tasks to be strictly larger than Budi's. If it is possible, you should output one (any) working plan on when she should pop the balloons. \n\nNote that if Ayu solves a task at exactly the $M^(t h)$ minute, then the task is considered as solved. Similarly, if Budi solves a task at exactly the $M^(t h)$ minute, then the task is considered as solved, except if Ayu decides to pop a balloon at the same time. Also, Ayu can pop a balloon as soon as she receives it. Ayu cannot pop more than one balloon at the same minute. She also cannot pop any balloon after the $M^(t h)$ minute mark.\n\nInput begins with a line containing two integers: $N$ $M$ ($1 <= N <= 100000$; $1 <= M <= 10^9$) representing the number of tasks and duration of the competition, respectively. The second line contains $N$ integers $A_i$ ($1 <= A_i <= 10^9$) representing the time needed by Ayu to solve the $i^(t h)$ task. The third line contains $N$ integers $B_i$ ($1 <= B_i <= 10^9$) representing the time needed by Budi to solve the $i^(t h)$ task.\n\nIf it is not possible for Ayu to win the competition by having *strictly* larger number of solved tasks than Budi, simply output $-1$ in a line. Otherwise, output begins with an integer $K$ in a line representing the number of balloons Ayu needs to pop. The next line contains $K$ integers (each separated by a single space), sorted by *increasing order*, representing the minute in which Ayu should pop a balloon. You may output any configuration as long as it's valid, i.e. Ayu has at least one balloon *when* she pops a balloon, Ayu is not popping a balloon after the contest is over, Ayu is not popping more than one balloon at the same minute, and the configuration causes Ayu to have a larger number of solved tasks than Budi.\n\n_Explanation for the sample input/output #1_\n\nAyu gets her first balloon at minute $9$, while at that time, Budi already solved the first task (at minute $4$) and is currently doing his second task which needs $5$ more minutes (projected to finish at minute $14$). Ayu pops his first balloon at minute $12$, i.e. $2$ minutes before Budi finish the second task, causing Budi to repeat the second task. Now, the projected time for Budi to finish the second task is at minute $22$. At minute $19$, Ayu gets her second balloon and pops it right away, causing Budi to repeat the second task again. Now, the projected time for Budi to finish the second task is at minute $29$. At minute $29$, Ayu gets his third balloon, and at the same time, Budi also solved the second task. The competition ends at minute $30$. In total, Ayu solved $3$ tasks, while Budi only managed to solve $2$ tasks.\n\n_Explanation for the sample input/output #3_\n\nAyu cannot solve the first task during the competition, so no balloon for her to play with.\n\n"},{"iden":"input","content":"Input begins with a line containing two integers: $N$ $M$ ($1 <= N <= 100000$; $1 <= M <= 10^9$) representing the number of tasks and duration of the competition, respectively. The second line contains $N$ integers $A_i$ ($1 <= A_i <= 10^9$) representing the time needed by Ayu to solve the $i^(t h)$ task. The third line contains $N$ integers $B_i$ ($1 <= B_i <= 10^9$) representing the time needed by Budi to solve the $i^(t h)$ task."},{"iden":"output","content":"If it is not possible for Ayu to win the competition by having *strictly* larger number of solved tasks than Budi, simply output $-1$ in a line. Otherwise, output begins with an integer $K$ in a line representing the number of balloons Ayu needs to pop. The next line contains $K$ integers (each separated by a single space), sorted by *increasing order*, representing the minute in which Ayu should pop a balloon. You may output any configuration as long as it's valid, i.e. Ayu has at least one balloon *when* she pops a balloon, Ayu is not popping a balloon after the contest is over, Ayu is not popping more than one balloon at the same minute, and the configuration causes Ayu to have a larger number of solved tasks than Budi."},{"iden":"examples","content":"Input4 30\n9 10 10 10\n4 10 5 10\nOutput2\n12 19\nInput5 50\n10 10 10 10 10\n15 12 19 17 20\nOutput0\n\nInput5 10\n15 10 5 5 5\n9 10 10 10 10\nOutput-1\n"},{"iden":"note","content":"_Explanation for the sample input/output #1_Ayu gets her first balloon at minute $9$, while at that time, Budi already solved the first task (at minute $4$) and is currently doing his second task which needs $5$ more minutes (projected to finish at minute $14$). Ayu pops his first balloon at minute $12$, i.e. $2$ minutes before Budi finish the second task, causing Budi to repeat the second task. Now, the projected time for Budi to finish the second task is at minute $22$. At minute $19$, Ayu gets her second balloon and pops it right away, causing Budi to repeat the second task again. Now, the projected time for Budi to finish the second task is at minute $29$. At minute $29$, Ayu gets his third balloon, and at the same time, Budi also solved the second task. The competition ends at minute $30$. In total, Ayu solved $3$ tasks, while Budi only managed to solve $2$ tasks._Explanation for the sample input/output #3_Ayu cannot solve the first task during the competition, so no balloon for her to play with."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ t \\in \\mathbb{Z}^+ $ be the number of pretests.  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of submissions.  \nLet $ S = \\{s_1, s_2, \\dots, s_n\\} $ be the set of submission verdicts, where each $ s_i \\in \\{0,1\\}^t $ represents the outcome of submission $ i $ on each pretest.  \n\nLet $ \\pi: \\{1, \\dots, t\\} \\to \\{1, \\dots, t\\} $ be a permutation (ordering) of pretests.  \nFor a submission $ s_i $, let $ k_i(\\pi) = \\min\\{ j \\in \\{1, \\dots, t\\} \\mid s_i[\\pi(j)] = 0 \\} $ if such $ j $ exists, otherwise $ k_i(\\pi) = t $.  \nThe cost of submission $ s_i $ under $ \\pi $ is $ k_i(\\pi) $.  \n\n**Constraints**  \n1. $ 1 \\le t \\le 20 $  \n2. $ 1 \\le n \\le 2 \\times 10^5 $  \n3. Each $ s_i $ is a binary string of length $ t $.  \n\n**Objective**  \nFind a permutation $ \\pi $ that minimizes the total cost:  \n$$\nC(\\pi) = \\sum_{i=1}^{n} k_i(\\pi)\n$$  \nAmong all such optimal $ \\pi $, select the lexicographically smallest one.  \n\nOutput:  \n- The minimal total cost $ \\min_{\\pi} C(\\pi) $  \n- The lexicographically smallest optimal permutation $ \\pi $","simple_statement":"Given n submissions and t pretests, each submission passes or fails each pretest (marked as '1' or '0'). You can reorder the pretests. For each submission, the system runs pretests in order until the first failure (or all if it passes). Find the minimum total number of test runs across all submissions, and the lexicographically smallest pretest order that achieves it.","has_page_source":false}