← 返回题目列表

AtCoder · tenka1_2012_qualA_3

C. 敌対的引用

中文机器翻译题面 查看原题

問題文

N 组。
每个组都有一个“组1”至“组N”。
有一天,一个小组拜访了另一个小组,然后反复引用了其中的内容。


组A 是组 Suppose you are aggressive towardsB .那时

  • 组A 是组 呼叫B 时,在群组名称之后 添加 w 和“组Bw”。 When quoting
  • 组A 是组 呼叫B , groupB 的备注用双引号括起来 (") and quote it at the back. Add ww when 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.

部分点

Inputs with a small number of groups ( The number of groups that may have performed 1 \leq N \leq 100 ) 是正确的,那么100 部分积分换满分 50 点。 如果您正确回答了所有满足

出力

発言 s is printed to standard output. 1 行。
请注意,行尾需要换行。 定义

入力例 1

3 6
1 2
1 3
2 1
2 3
3 1
3 2
"group1w"ww

出力例 1

3
  • group1w was said by group2 or group3.
  • 组2是 如果你说 group1w , "group1w"ww was said by group1 or group3.
  • 组3是 group1w , "group1w"ww was said by group1 or group2.
  • Therefore, the statement The group that may have committed "group1w"ww is 有 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.