P27056 [AtCoder] Stalker
普及+
题目描述

Problem Description

Tuplis has arrived in Tech Room Country.
Tech Room Country consists of $ N $ towns numbered from $ 1 $ to $ N $ and $ N-1 $ roads, each connecting town $ A_i $ and town $ B_i $ bidirectionally.
Any town can be reached from any other town by traversing several roads.
It is known that there are photos of Gabriel in $ M $ towns, $C_1,\ C_2,\ C_3,\ ...,\ C_M$, and Tuplis wants to collect all these photos.
However, since staying outside for too long will exceed her curfew, she decided to visit the towns without passing through the same town twice to collect the photos.
Tuplis can start in any town and end her photo collection in any town. Determine if Tuplis can collect all the photos. If she can, output Yes; otherwise, output trumpet.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $
$ A_1 $ $ B_1 $
$ A_2 $ $ B_2 $
$ ⋮ $
$ A_{N-2} $ $ B_{N-2} $
$ A_{N-1} $ $ B_{N-1} $
$ C_1 $ $ C_2 $ ... $ C_{M-1} $ $ C_M $

Output Format

Output Yes if Tuplis can collect all the photos; otherwise, output trumpet.

Sample Input and Output

Sample Input #1

3 21 21 31 2

Sample Output #1

Yes

Sample Input #2

5 31 22 33 44 53 4 5

Sample Output #2

Yes

Sample Input #3

4 31 21 31 42 3 4

Sample Output #3

trumpet

Notes/Hints

Constraints

  • All inputs are integers.
  • $1\ \leq\ N\ \leq\ 10^5$
  • $1\ \leq\ A_i,\ B_i\ \leq\ N$
  • $1\ \leq\ M\ \leq\ N$
  • $1\ \leq\ C_i\ \leq\ N$
  • $C_i\ \neq\ C_j$ $(i\ \neq\ j)$
  • The given graph is a tree.

Subtasks

There are $ 2 $ subtasks for this problem:

  1. (200 points) $N\ \leq\ 2\ 000$
  2. (200 points) No additional constraints.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 21 21 31 2
样例输出
Yes