{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDlsj is competing in a contest with $n (0 \u0026lt; n \\le 20)$ problems. And he knows the answer of all of these problems.\u003c/p\u003e\u003cp\u003eHowever, he can submit $i$-th problem if and only if he has submitted (and passed, of course) $s_i$ problems, the $p_{i, 1}$-th, $p_{i, 2}$-th, $...$, $p_{i, s_i}$-th problem before.$(0 \u0026lt; p_{i, j} \\le n,0 \u0026lt; j \\le s_i,0 \u0026lt; i \\le n)$ After the submit of a problem, he has to wait for one minute, or cooling down time to submit another problem. As soon as the cooling down phase ended, he will submit his solution (and get \"Accepted\" of course) for the next problem he selected to solve or he will say that the contest is too easy and leave the arena.\u003c/p\u003e\u003cp\u003e\"I wonder if I can leave the contest arena when the problems are too easy for me.\"\u003cbr\u003e\"No problem.\"\u003cbr\u003eāā CCF NOI Problem set\u003c/p\u003e\u003cp\u003eIf he submits and passes the $i$-th problem on $t$-th minute(or the $t$-th problem he solve is problem $i$), he can get $t \\times a_i + b_i$ points. $(|a_i|, |b_i| \\le 10^9)$.\u003c/p\u003e\u003cp\u003eYour task is to calculate the maximum number of points he can get in the contest.\u003c/p\u003e\u003ch3\u003eInput\u003c/h3\u003e\u003cp\u003eThe first line of input contains an integer, $n$, which is the number of problems.\u003c/p\u003e\u003cp\u003eThen follows $n$ lines, the $i$-th line contains $s_i + 3$ integers, $a_i,b_i,s_i,p_1,p_2,...,p_{s_i}$as described in the description above.\u003c/p\u003e\u003ch3\u003eOutput\u003c/h3\u003e\u003cp\u003eOutput one line with one integer, the maximum number of points he can get in the contest.\u003c/p\u003e\u003ch3\u003eHint\u003c/h3\u003e\u003cp\u003eIn the first sample.\u003c/p\u003e\u003cp\u003eOn the first minute, Dlsj submitted the first problem, and get $1 \\times 5 + 6 \u003d 11$ points.\u003c/p\u003e\u003cp\u003eOn the second minute, Dlsj submitted the second problem, and get $2 \\times 4 + 5 \u003d 13$ points.\u003c/p\u003e\u003cp\u003eOn the third minute, Dlsj submitted the third problem, and get $3 \\times 3 + 4 \u003d 13$ points.\u003c/p\u003e\u003cp\u003eOn the forth minute, Dlsj submitted the forth problem, and get $4 \\times 2 + 3 \u003d 11$ points.\u003c/p\u003e\u003cp\u003eOn the fifth minute, Dlsj submitted the fifth problem, and get $5 \\times 1 + 2 \u003d 7$ points.\u003c/p\u003e\u003cp\u003eSo he can get $11+13+13+11+7\u003d55$ points in total.\u003c/p\u003e\u003cp\u003eIn the second sample, you should note that he doesn\u0027t have to solve all the problems.\u003c/p\u003e"}},{"title":"Sample 1","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\u003e5\n5 6 0\n4 5 1 1\n3 4 1 2\n2 3 1 3\n1 2 1 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e55\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}},{"title":"Sample 2","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\u003e1\n-100 0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}}]}