Robotic Cow Herd#10567

Robotic Cow Herd

1 second
128 megabytes
Very hard

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. Each robot has distinct locations where microcontrollers must be installed, with exactly one microcontroller installed at each location. For each location, Bessie can choose from several different models of microcontrollers, each with its own cost.

For her herd of robotic cows to look convincing to Farmer John, no two robots should behave identically. Therefore, no two robots may have exactly the same set of microcontrollers. In other words, for every pair of robots, there must be at least one location where they use different microcontroller models. It is guaranteed that there are always enough different microcontroller models to satisfy this condition.

Bessie wants to build her robotic herd as cheaply as possible. Help her determine the minimum possible cost of constructing robots!

Input

The first line contains two integers and k~(1 \le n \le 10^5, 1 \le k \le 10^5).

The following lines describe the microcontroller models available at each location. The -th line starts with an integer m_i~(1 \le m_i \le 10), giving the number of models available at location . This is followed by m_i integers P_{i,j}~(1 \le P_{i,j} \le 10^8), giving the costs of these models.

Output

Print the minimum possible cost to construct robots.

Examples

Example 1

Loading
Loading