{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003ePutata is preparing the RPG Pro League (RPL) held by the International Computer Playing Company (ICPC). In this RPG game, the player will wear $$$n$$$ items at the same time. Each item can offer the player several points of power. There is a magic buff in the game, which can upgrade each item such that they can offer several points of bonus power.\u003c/p\u003e\u003cp\u003eHowever, the buff is limited, it can only buff at most $$$k$$$ points of power. Formally, assume the player is wearing nothing initially, and then will wear all the $$$n$$$ items one by one. The game server will scan through all these $$$n$$$ items one by one, according to the permutation that the player wears them. When the server is scanning the $$$i$$$-th item, which can offer $$$p_i$$$ points of power, let $$$sum\u003d\\sum_{1\\leq j\u0026lt;i}p_j$$$ denoting the total points of power scanned before: \u003c/p\u003e\u003cul\u003e \u003cli\u003e If $$$sum+p_i\\leq k$$$, the whole item will be upgraded. The buff will offer $$$w_{i,p_i}$$$ points of bonus power. \u003c/li\u003e\u003cli\u003e If $$$sum\\geq k$$$, the item won\u0027t be upgraded. The buff will offer nothing. \u003c/li\u003e\u003cli\u003e Otherwise, only a part of the item will be upgraded. The buff will offer $$$w_{i,k-sum}$$$ points of bonus power. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003ePutata is clever, he soon realized that he can adjust the permutation to wear these $$$n$$$ items to gain more points of bonus power! Unfortunately, Putata doesn\u0027t know the optimal permutation, please write a program to help him.\u003c/p\u003e\u003cp\u003eThe behavior of the magic buff performed by the game server is a bug. The game code can work all thanks to bugs, so it is possible that $$$w_{i,a}\u0026gt;w_{i,b}$$$ where $$$a\u0026lt;b$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 3\\,000$$$, $$$0\\leq k\\leq 3\\,000$$$), denoting the number of items and the limit $$$k$$$.\u003c/p\u003e\u003cp\u003eEach of the following $$$n$$$ lines starts with an integer $$$p_i$$$ ($$$1\\leq p_i\\leq 10$$$), denoting the base power of the $$$i$$$-th item, followed by $$$p_i$$$ integers $$$w_{i,1},w_{i,2},\\ldots,w_{i,p_i}$$$ ($$$1\\leq w_{i,j}\\leq 10^5$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput a single line containing an integer, denoting the maximum points of total bonus power that can be reached. The base power is not included in the answer.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 5\n2 1 3\n2 1 1\n2 3 1\n2 1 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e9\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}