#abc286g. [abc286_g]Unique Walk
[abc286_g]Unique Walk
Problem Statement
You are given a simple connected undirected graph with vertices and edges.
The vertices of are numbered vertex , vertex , , and vertex , and its edges are numbered edge , edge , , and edge . Edge connects vertex and vertex .
You are also given a subset of the edges: .
Determine if there is a walk on that contains edge exactly once for all .
The walk may contain an edge not in any number of times (possibly zero).
What is a walk? A walk on an undirected graph is a sequence consisting of vertices ( is a positive integer) and edges occurring alternately, , such that edge connects vertex and vertex . The sequence may contain the same edge or vertex multiple times. A walk is said to contain an edge exactly once if and only if there is exactly one such that .
Constraints
- $N-1 \\leq M \\leq \\min(\\frac{N(N-1)}{2},2\\times 10^5)$
- If , then .
- is connected.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if there is a walk satisfying the condition in the Problem Statement; print No
otherwise.
Sample Input 1
6 6
1 3
2 3
3 4
4 5
4 6
5 6
4
1 2 4 5
Sample Output 1
Yes
The walk $(v_1,e_1,v_3,e_3,v_4,e_4,v_5,e_6,v_6,e_5,v_4,e_3,v_3,e_2,v_2)$ satisfies the condition, where denotes vertex and denotes edge .
In other words, the walk travels the vertices on in this order: .
This walk satisfies the condition because it contains edges , , , and exactly once each.
Sample Input 2
6 5
1 2
1 3
1 4
1 5
1 6
3
1 2 3
Sample Output 2
No
There is no walk that contains edges , , and exactly once each, so No
should be printed.