题目描述
Problem Description
A company sells $ N $ types of mobile phones, numbered from model $ 1 $ to model $ N $.
There are also $ M $ frequency bands, numbered from frequency band $ 1 $ to frequency band $ M $.
The mobile phone of model $ i $ supports only $ K_i $ frequency bands: $A_{i,\ 1},\ A_{i,\ 2},\ A_{i,\ 3},\ \dots,\ A_{i,\ K_i}$.
You have decided to buy one of the company's mobile phones that meets the following condition:
- Supports at least $ Q $ out of the $ P $ frequency bands: $B_1,\ B_2,\ B_3,\ \dots,\ B_P$.
Output the number of candidate models of mobile phones you can buy.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ K_1 $ $A_{1,\ 1}$ $A_{1,\ 2}$ $A_{1,\ 3}$ $\dots$ $A_{1,\ K_1}$ $ K_2 $ $A_{2,\ 1}$ $A_{2,\ 2}$ $A_{2,\ 3}$ $\dots$ $A_{2,\ K_2}$ $ K_3 $ $A_{3,\ 1}$ $A_{3,\ 2}$ $A_{3,\ 3}$ $\dots$ $A_{3,\ K_3}$ $\hspace{67pt}\ \vdots$ $ K_N $ $A_{N,\ 1}$ $A_{N,\ 2}$ $A_{N,\ 3}$ $\dots$ $A_{N,\ K_N}$ $ P $ $ Q $ $ B_1 $ $ B_2 $ $ B_3 $ $\dots$ $ B_P $
Output Format
Output the answer.
Sample Input and Output
Sample Input #1
4 4
1 4
2 3 1
3 2 1 3
2 2 4
2 1
2 4
Sample Output #1
3
Sample Input #2
4 4
3 2 3 4
1 2
2 1 3
4 1 2 3 4
3 1
1 3 4
Sample Output #2
3
Sample Input #3
1 2
1 1
1 1
2
Sample Output #3
0
Notes/Hints
Constraints
- $1\ \le\ N\ \le\ 50$
- $1\ \le\ M\ \le\ 50$
- $1\ \le\ K_i\ \le\ M$
- $1\ \le\ A_{i,\ j}\ \le\ M$
- $j\ \neq\ k$ implies $A_{i,\ j}\ \neq\ A_{i,\ k}$
- $1\ \le\ Q\ \le\ P\ \le\ M$
- $1\ \le\ B_i\ \le\ M$
- $i\ \neq\ j$ implies $B_i\ \neq\ B_j$
- All inputs are integers
Sample Explanation 1
The frequency bands supported by each model are as follows:
- Model $ 1 $: Frequency band $ 4 $
- Model $ 2 $: Frequency bands $1,\ 3$
- Model $ 3 $: Frequency bands $1,\ 2,\ 3$
- Model $ 4 $: Frequency bands $2,\ 4$
Models $1,\ 3,\ 4$ support at least one of the frequency bands $2,\ 4$.
Sample Explanation 2
Models $1,\ 3,\ 4$ meet the condition.
Sample Explanation 3
There may be no models that meet the condition.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分