2665. The King Of Fighters

单点时限: 2.0 sec

内存限制: 256 MB

HH is a good KOF player. He never loses until meet Teddy. But Teddycouldn’t use every role to beat HH. So HH wants to choose some roles first, then Teddy just only chooses the remaining roles. And HH knows that he can easily beat Teddy if they both use some specific roles. So he wants to find a strategy to beat Teddy.

Please help HH to calculate the minimum number of roles he has to choose, so that he could beat Teddy.If Teddy’s roles are all beaten by HH’s roles,we say HH win.

输入格式

The first line with two numbers n, m (1<=n,m<=100)

The second line with n name, each indicates the name of one role (the length of name is smaller than 20)

Then m lines follow, each line with a name A and a number mi(1<=mi <= n), then mi names B(i, j) follow, indicates if HH use role A he could beat Teddy use B(i, j).

输出格式

Output a number indication the minimum number HH has to choose.

样例

Input
3 2
KYO MAI IORI
KYO 1 MAI
IORI 1 MAI
3 1
BENIMARU LEONA TERRY
BENIMARU 2 LEONA TERRY
3 1
BENIMARU LEONA TERRY
BENIMARU 1 LEONA
Output
2
1
2
Hitn:
HH choose KYO and IORI
HH choose BENIMARU
HH choose BENIMARU and TERRY

2 人解决,9 人已尝试。

5 份提交通过,共有 27 份提交。

9.6 EMB 奖励。

创建: 15 年,3 月前.

修改: 7 年,2 月前.

最后提交: 10 年,12 月前.

来源: N/A

题目标签