Tea Party
In a department of a large organization, there are n employees. Like most employees in this organization, they enjoy drinking tea during their work breaks. They are quite disciplined and take exactly one break per day, during which they drink tea. To ensure this break is as enjoyable as possible, each employee must drink a type of tea that is among their favorites. On different days, an employee may choose different types of tea. For convenience, we will number the types of tea from 1 to m.
Recently, the department employees purchased a large set of tea bags, which includes a_1 bags of tea type 1, a_2 bags of tea type 2, ..., a_m bags of tea type m. They now want to determine the maximum number of days they can stretch their supply so that each day, every employee receives a bag of tea from one of their favorite types.
Each employee in the department drinks exactly one cup of tea per day, brewed from one tea bag. Tea bags cannot be reused.
Input
The first line contains two integers n and m (1 ≤ n, m ≤ 50). The second line contains m integers a_1, ..., a_m (1 ≤ a_i ≤ 10^6 for all i from 1 to m).
The following n lines describe the favorite tea types for the i-th employee in the department. Each line starts with a positive number k_i — the number of favorite tea types for this employee, followed by k_i distinct numbers from 1 to m — representing these favorite types.
Output
Output a single integer — the maximum number of days the tea supply can last.