In the event of technical difficulties with Szkopuł, please contact us via email at szkopul@fri.edu.pl.

If you are familiar with IRC chat, the support team is also reachable on PIRC network (`irc.pirc.pl`

) in `#szkopul`

channel. If you are not, just use email.

Please do not ask us things like "how to solve task XYZ?".

Please remember that the support team has to sleep sometimes or go to work in real life.

<Submit a solution> [0/1]**Task statistics**

Number of users: 53

Number of users with 1 points: 37

Average result: 0.6981

# The Prices

### Memory limit: 256 MB

## Input

## Output

## Example

Number of users: 53

Number of users with 1 points: 37

Average result: 0.6981

Byteasar works as a Purchasing Manager at one of Byteotian restaurants. Every evening he receives a shopping list from his manager. Food products must be purchased the next day, in the morning. Byteasar should buy exactly one piece of each product from the list. Manager is always pressing that the total costs are as little as possible.

Byteasar sits down in the evening with his computer and checks the prices of all needed products at local grocery wholesalers. He also knows the cost of the trips from the restaurant to each wholesale and back. Now Byteasar must decide which products are to be purchased at each of the warehouses.

For each wholesale, where Byteasar decided to buy some products, he does as follows. He would go from the restaurant to the warehouse, will do the shopping and immediately bring the purchased products back to the restaurant. Luckily, the boot of his car is big enough that it eliminates the need to visit any of the warehouses more than once, as all the purchased goods can be delivered in one go. Food products are highly perishable, so during one trip Byteasar can make purchases only at one warehouse.

Write a program that will help Byteasar to calculate the cheapest way of making all the purchases.

The first line of input contains two integers and (, ) denoting the number of wholesalers and the number of products that Byteasar should buy. Next lines contain descriptions of the prices at individual wholesalers.

The first number in the -th of these lines, (), describes the trip cost from the restaurant to the -th warehouse (including the return cost). It is followed by a sequence of integers (): number denotes the price of -th product in the -th warehouse.

Your program should output a single line containing a single integer denoting the sum of the product prices and the cost of the trips to warehouses selected by Byteasar in the cheapest possible purchase plan.

For the input data:

3 4 5 7 3 7 9 2 1 20 3 2 8 1 20 1 1

the correct result is:

16

**Explanation of the example:**
Byteasar buys the product number 2 in the first warehouse,
and all the other products in the second one.
So he does not have to visit the third warehouse.

*Task author: Jakub Radoszewski.*