{"raw_statement":[{"iden":"problem statement","content":"We have $N$ cards numbered $1$ to $N$.  \nCard $i$ has an integer $A_i$ written on the front and an integer $B_i$ written on the back. Here, $\\sum_{i=1}^N (A_i + B_i) = M$.  \nFor each $k=0,1,2,...,M$, solve the following problem.\n\n> The $N$ cards are arranged so that their front sides are visible. You may choose between $0$ and $N$ cards (inclusive) and flip them.  \n> To make the sum of the visible numbers equal to $k$, at least how many cards must be flipped? Print this number of cards.  \n> If there is no way to flip cards to make the sum of the visible numbers equal to $k$, print $-1$ instead."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $0 \\leq M \\leq 2 \\times 10^5$\n*   $0 \\leq A_i, B_i \\leq M$\n*   $\\sum_{i=1}^N (A_i + B_i) = M$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_1$ $B_1$\n$A_2$ $B_2$\n$\\vdots$ \n$A_N$ $B_N$"},{"iden":"sample input 1","content":"3 6\n0 2\n1 0\n0 3"},{"iden":"sample output 1","content":"1\n0\n2\n1\n1\n3\n2\n\nFor $k=0$, for instance, flipping just card $2$ makes the sum of the visible numbers $0+0+0=0$. This choice is optimal.  \nFor $k=5$, flipping all cards makes the sum of the visible numbers $2+0+3=5$. This choice is optimal."},{"iden":"sample input 2","content":"2 3\n1 1\n0 1"},{"iden":"sample output 2","content":"\\-1\n0\n1\n-1"},{"iden":"sample input 3","content":"5 12\n0 1\n0 3\n1 0\n0 5\n0 2"},{"iden":"sample output 3","content":"1\n0\n1\n1\n1\n2\n1\n2\n2\n2\n3\n3\n4"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}