Supporting everyone
Alice is attending a sport event with many national teams and one thing is important to her: supporting every country.
There are countries represented and she has two ways to support a country: either have the flag drawn on her or have a pin with the name of the country. Alice has a list containing, for each country, the colours needed to make its flag. A total of colours that may appear across all flags and, in Alice's list, each colour is conveniently represented as an integer between and .
Each crayon and pin cost , but her budget is tight... Can you help her find the minimum she can spend to support everyone?
Input
The first line contains the two numbers and . Then follow lines, grouped in pairs; the -th and -th lines represent the -th country. More precisely, the -th line contains a single integer : the number of colours in the flag of the ith country. Then, the -th line contains numbers ; these are the colours in the flag of the -th country. For all , the colour numbers are pairwise distinct.
Output
Print a single number: the minimum amount Alice can spend on crayons and pins to represent every country.
Examples
Sample 1. The three first countries could be France, the Netherlands, and the Czech Republic, all represented by blue , white , and red . The three next countries could be Italy, Hungary, and Bulgaria, with green , white and red . The last one could be Germany, with black , red , and yellow . The minimum cost is : we buy four (blue, green, white, and red) crayons and one pin (for Germany).
Sample 2. We can buy two crayons for the colours and and buy two pins for a total cost of . All six countries with flag colours (red) and (white) could be Canada, Indonesia, Japan, Malta, Monaco, and Poland. The flag of Belize has colours, including red and white, and the fifth country could be Botswana.