In a computer club, a CD exchange operates, allowing you to trade any disc for another from the catalog, either directly or through a series of exchanges. The catalog contains distinct discs, numbered from to . For each disc (i = 1 \ldots N), the catalog lists the discs that can be obtained by exchanging disc . Each exchange costs currency unit.
The first line contains the integers and .
The next lines, for each disc , list the discs that can be obtained by exchanging disc .
Output the minimum total amount required to obtain all discs from the catalog through exchanges.
All numbers are natural and do not exceed .
Example 1