問題文
N 组。
每个组都有一个“组1”至“组N”。
有一天,一个小组拜访了另一个小组,然后反复引用了其中的内容。
组A 是组 Suppose you are aggressive towardsB .那时
- 组A 是组
呼叫B 时,在群组名称之后
添加
w和“组Bw”。 When quoting - 组A 是组
呼叫B , groupB 的备注用双引号括起来 (
") and quote it at the back. Addwwwhen speaking.
另外,组 假设您对A 是组 Suppose you are aggressive towardsB 没有攻击性。那时 When calling
- 组A 是组 呼叫B , "groupB”。 用
- 组A 是组
呼叫B , groupB 的备注用双引号括起来 (
"包围它来引用它,然后说出它而不在后面添加任何内容。
For example, when group2 is aggressive towards group1, group2
说 group1w 。
此外,当group3对group2有攻击性时,group3 "group1w"ww 。
另外,当 group2 对 group3 没有攻击性时,group2 group3 。
此外,当group1对group2没有攻击性时,group1 "group3" 。
组A 是组
Suppose you are aggressive towardsB aggressive, but groupB 是组A may not be offensive.
也有一些群体会自嘲或攻击自己。
是 小于或等于 1 您将收到一份声明,因此请回答可能发表该声明的团体总数。
入力
N M a_1 b_1 a_2 b_2 : : a_M b_M s
- 1 line 是一个整数,代表组数 N (1 \leq N \leq 10^5) , an integer representing an adversarial relationship The M (1 \leq M \leq 10000)。
- 2 从行 M row gives the group's hostile relationship.
- a_i, b_i (1 \leq a_i, b_i \leq N) 是一个组 a_i 是一组 Indicates being aggressive towards b_i .
- i \neq j 然后, a_i \neq a_j 或 至少 b_i \neq b_j 。
- M+2 Line is the statement of a certain group. s 。 表示
- s 的字符串长度为 300 下面。
- 至少 1 The group may have made a statement.
部分点
出力
请注意,行尾需要换行。 定义
入力例 1
3 6 1 2 1 3 2 1 2 3 3 1 3 2 "group1w"ww
出力例 1
3
group1wwas said by group2 or group3.- 组2是
如果你说
group1w,"group1w"wwwas said by group1 or group3. - 组3是
group1w,"group1w"wwwas said by group1 or group2. - Therefore, the statement
The group that may have committed
"group1w"wwis 有 3 个组:group1、group2 和 group3。
入力例 2
3 2 1 2 2 3 "group3w"
出力例 2
2
- There are two groups that may have made this comment: group2 and group3.
入力例 3
3 1 1 1 ""group1w"ww"ww
出力例 3
1
- You may also call out your own group or quote what your own group has said.