|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||512 MB||1||1||1||100.000%|
Gigel wants to test his cooking abilities and goes to the market to get some supplies. At the market, there are m types of objects sold as promotional packages for a period of n days. On the ith day, Gigel has two options: he either buys the promotional package available on that day or not. The promotional package is represented by a non-empty subset of the set of the m types of objects and it has a certain price.
Knowing m, n, the price and the composition of each of the n promotional packages, find the minimal price that Gigel should pay in order to buy at least one object of each of the m types.
The first line of the input contains 2 numbers, m and n.
The next n lines will describe the n promotional packages in this way: the (i+1)th line (1 ≤ i ≤ n) contains nr and p, which stand for the number of objects in the promotional package from that day and its price. Then, on the same line, there are given nr numbers which represent the indexes of the objects that belong to that package.
In the output print a positive integer number equal to the minimal price that should be paid in order to buy at least one object of every type.
5 4 3 10 1 3 2 2 8 1 4 3 11 5 4 3 5 27 1 4 2 3 5
The chosen packages are the first and the third ones, thus obtaining a minimal cost of 10+11 = 21. Note that Gigel buys one object of type 1, one object of type 2, two objects of type 3, one object of type 4 and one object of type 5.