{"raw_statement":[{"iden":"background","content":"译自 [XXVIII Olimpiada Informatyczna - III etap](https://sio2.mimuw.edu.pl/c/oi28-3/dashboard/) [Les Bitérables](https://szkopul.edu.pl/problemset/problem/Lpz563_ATiESIrNZxiT5bwIx/statement/)。\n\nd1t2。"},{"iden":"statement","content":"有 $t$ 个时刻，第 $i$ 个时刻给出了局面 $p_1,p_2,\\dots,p_{s_i}$，表示在数轴的 $(0,d)$ 范围内，有且仅有 $p_1,p_2,\\dots,p_{s_i}$ 这些位置上有物品。\n\n在 $0$ 位置和 $d$ 位置有无穷多个物品。\n\n你可以花费一个代价，将一个物品向左移动一个位置或向右移动一个位置。\n\n问你在相邻两个时刻之间，把前一个局面转化为后一个局面，最少需要多少代价。"},{"iden":"input","content":"第一行两个正整数 $n,d$。\n\n接下来 $n$ 行，每行描述一个时刻的局面，首先是一个非负整数 $s_i$，接下来是 $s_i$ 个正整数，分别为 $p_1,p_2,\\dots,p_{s_i}$。保证 $0<p_1<p_2<\\dots<p_{s_i}<d$。"},{"iden":"output","content":"$n-1$ 行，每行一个整数，你的答案。"},{"iden":"note","content":"对于所有数据，$2\\leq n\\leq 500000$，$2\\leq d\\leq 10^{12}$，$\\sum s_i\\leq 500000$。\n\n| 子任务编号 | 附加限制 | 分数 |\n| :----------: | :----------: | :----------: |\n| 1 | $s_i\\leq 1$ | 5 |\n| 2 | $s_i\\leq 3$ | 10 |\n| 3 | $d\\leq 7$ | 12 |\n| 4 | $\\sum s_i\\leq 5000$ | 27 |\n| 5 | 如果 $s_i>0$，那么 $p_{s_i}=p_1+s_i-1$ | 11 |\n| 6 |  | 35 |\n"}],"translated_statement":null,"sample_group":[["3 10\n2 4 7\n3 3 6 8\n1 5\n","4\n6"],["见附件","6252500\n6252500\n"],["见附件","999990000\n999990000\n999990000\n999990000\n"],["生成器：/paste/3igmip11","生成器：/paste/fusadpm0"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}