Recruiting Teammates

Pick the fewest of up to 10 students whose solvable problem sets cover all N problems, or print -1 when coverage is impossible.

Easy3Brute forceBit manipulationInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

November 28, 2015 is the day of the long awaited first IUPC. IUPC is short for Inha University Programming Contest, a programming contest open to every undergraduate in the college of information technology engineering at Inha University. The total prize is 11 billion won, lunch and snacks are served, and gift certificates are drawn for many of the teams.

Two things make this contest different from the others. There are a lot of problems, and there is no cap on team size.

Kangho, a student in the department of computer engineering, wants to gather teammates for the contest. He wants to solve every problem and win. Since his own share of the prize shrinks as the team grows, he wants to win with as few teammates as possible.

You are given the list of students Kangho may pick and the numbers of the problems each of them can solve. Build the smallest team that can solve every problem in the contest.

Input

The first line contains the number of problems NN and the number of students Kangho may pick as teammates MM, separated by a space. NN and MM are natural numbers between 1 and 10.

Each of the next MM lines describes one student in order. The ii-th of these lines starts with OiO_i, the number of problems student ii can solve, followed by the numbers of those problems Pi1,Pi2,,PiOiP_{i1}, P_{i2}, \ldots, P_{iO_i}, separated by spaces. Here 1iM1 \le i \le M, 1jOi1 \le j \le O_i, and 1PijN1 \le P_{ij} \le N.

Output

Find the smallest team that can solve every problem and print the number of its members. If no team can solve every problem, print -1.

Hint

In the first example, picking student 3 and student 4 gives a team that solves every problem from 1 to 5. Picking students 1, 2, and 4 also solves every problem, but that team has 3 members, so it cannot be the answer.