P29581 [洛谷] [COCI2020-2021#4] Pizza
普及
题目描述

Problem Description

At the end of a long and painful day, Mirko decides to order a pizza to rejuvenate himself. Among the pile of papers on his desk, he finds a flyer from a nearby pizza shop.

The pizza shop offers $m$ different types of pizzas. The ingredients of the pizzas are numbered using positive integers. The $i$-th pizza has $k_i$ ingredients, numbered as $b_{i,1}, b_{i,2}, \cdots, b_{i,k_i}$.

Mirko is particularly picky about his food. He dislikes $n$ ingredients, namely those numbered $a_1, a_2, \cdots, a_n$. Therefore, he wants to order a pizza that does not contain any of these disliked ingredients. Determine the number of pizzas Mirko can order.

Input Format

The first line contains an integer $n$, representing the number of ingredients Mirko dislikes. The next line contains $n$ distinct integers $a_i$, representing the numbers of the disliked ingredients.

The second line contains an integer $m$, representing the number of pizzas.

The following $m$ lines describe the pizzas. The $i$-th line starts with an integer $k_i$, representing the number of ingredients in the $i$-th pizza. This is followed by $k_i$ distinct integers $b_{i,j}$, representing the numbers of the ingredients in that pizza.

No two pizzas will have exactly the same ingredients.

Output Format

Output the number of pizzas Mirko can order.

Sample Input and Output

Sample Input #1

1 2
3
1 1
1 2
1 3

Sample Output #1

2

Sample Input #2

2 1 2
4
2 1 4
3 1 2 3
2 3 4
3 3 5 7

Sample Output #2

2

Sample Input #3

1 4
3
1 1
1 2
1 3

Sample Output #3

3

Notes

Data Size and Constraints

For $40\%$ of the test cases, $n = k_1 = k_2 = \cdots = k_m = 1$.

For $100\%$ of the test cases, $1 \le n, m, a_i, k_i, b_{i,j} \le 100$.

Note

This problem's score is set according to the original COCI contest, with a maximum score of $50$.

The problem is translated from COCI2020-2021 CONTEST #4 T1 Pizza.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 2 3 1 1 1 2 1 3
样例输出
2