Egg Shortages
题号:NC294493
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A severe egg shortage has struck the country, causing panic buying and supply disruptions. With supermarkets limiting purchases, you need to collect all n different types of specialty eggs (organic, free-range, omega-3 enriched, etc.) for your bakery business.

There are m supermarkets nearby, each stocking different varieties. The i-th supermarket carries k_i distinct egg types, listed as a_{i_1}, a_{i_2}, ..., a_{i_{k_i}}. Due to rationing and long queues, you want to minimize the number of supermarkets you visit while ensuring you obtain every required egg variety.

输入描述:

First line: Two integers n (total distinct egg types needed, 1 \le n \le 20) and m (number of supermarkets, 1 \le m \le 20).

Each of the next m lines describes a supermarket's egg selection. The first integer is k_i (number of egg types available of the i-th supermarket, 1 \le k_i \le n), then k_i distinct integers a_{i_1}, a_{i_2}, \ldots, a_{i_{k_i}} (1 \le a_{i_j} \le n) follow.

输出描述:

A single integer: the minimum number of supermarkets required to obtain all n egg types. If some types are unavailable, output -1.
示例1

输入

复制
5 3
3 1 2 3
2 2 4
3 3 4 5

输出

复制
2
示例2

输入

复制
2 1
1 1

输出

复制
-1