Tea Party#2505

Tea Party

2 seconds
256 megabytes
Very easy

In a department of a large organization, there are 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 to .

Recently, the department employees purchased a large set of tea bags, which includes a_1 bags of tea type , a_2 bags of tea type , ..., a_m bags of tea type . 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 and (1 \leq n, m \leq 50). The second line contains integers a_1, ..., a_m (1 \leq a_i \leq 10^6 for all from to ).

The following lines describe the favorite tea types for the -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 to — representing these favorite types.

Output

Output a single integer — the maximum number of days the tea supply can last.

Examples

Example 1

Loading
Loading