#1344
Unrated
Laminar Family
시간 제한
3s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

While studying combinatorial optimization, Lucas came across the notion of "laminar set family". A subset family F\mathcal{F} of some set Ω\Omega is called laminar if and only if it does not contain an empty set and for any two distinct sets A,BFA, B \in \mathcal{F} it is correct that either ABA \subset B or BAB \subset A or AB=A \cap B = \varnothing.

As an experienced problem setter Lucas always tries to apply each new piece of knowledge he gets as an idea for a programming competition problem. An area of his scientific interests covers recognition problems that usually sound like "Given some weird combinatorial property, check if the given structure satisfies it".

Lucas believes that the perfect programming competition problem should contain a cactus a tree in it. Trying to put together laminar sets and trees into a recognition problem, he finally came up with the following problem: given an undirected tree on nn vertices and a family F={F1,,Fk}\mathcal{F} = \{F_1, \ldots, F_k\} of sets, where FiF_i consists of all vertices belonging to the simple path between some two vertices aia_i and bib_i of the tree, check if the family F\mathcal{F} is a laminar family. Note that in this case Ω=V\Omega = V, and each FiVF_i \subseteq V.

As you can see, Lucas had succeeded in suggesting this problem to the programming contest. Now it is up to you to solve it.

입력

The first line of the input contains two integers nn and ff (1n,f1000001 \leq n, f \leq 100\,000) — the number of vertices in the tree and the number of elements in a family F\mathcal{F}.

Next n1n - 1 lines describe the tree structure. In the ii-th line there are two integers uiu_i and viv_i (1ui,vin1 \leq u_i, v_i \leq n, uiviu_i \neq v_i) — the indices of the vertices that are connected by the ii-th edge of the tree.

Next ff lines describe the sets forming the family F\mathcal{F}. In the ii-th line there are two integers aia_i and bib_i (1ai,bin1 \leq a_i, b_i \leq n), such that FiF_i consists of all vertices belonging to the simple path between vertices aia_i and bib_i in the tree (including aia_i and bib_i).

출력

Output the only word "Yes" or "No" depending on whether or not the given set family is laminar.

예제 입력 1

4 2
1 2
2 3
2 4
1 2
4 2

예제 출력 1

No

예제 입력 2

6 5
1 2
2 3
3 4
5 6
5 2
2 1
6 6
1 4
3 4
4 1

예제 출력 2

Yes
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.