logo AlgoBeat OnlineJudge
登录 注册

#201575. [USACO16DEC] Robotic Cow Herd P

内存限制:250 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Bessie is hoping to fool Farmer John by building a herd of realistic robotic cows ().

It turns out that building a robotic cow is somewhat complicated. There are () individual locations on the robot into which microcontrollers must be connected (so a single microcontroller must be connected at each location). For each of these locations, Bessie can select from a number of different models of microcontroller, each varying in cost.

For the herd of robotic cows to look convincing to Farmer John, no two robots should behave identically. Therefore, no two robots should have exactly the same set of microcontrollers. For any pair of robots, there should be at least one location at which the two robots use a different microcontroller model. It is guaranteed that there will always be enough different microcontroller models to satisfy this constraint.

Bessie wants to make her robotic herd as cheaply as possible. Help her determine the minimum possible cost to do this!

输入格式

The first line of input contains and separated by a space.

The following lines contain a description of the different microcontroller models available for each location. The th such line starts with (), giving the number of models available for location . This is followed by space separated integers giving the costs of these different models ().

输出格式

Output a single line, giving the minimum cost to construct robots.

样例

样例输入 1

3 10
4 1 5 3 10
3 2 3 3
5 1 3 4 6 6

样例输出 1

61