PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#DSU0000013. Đồ thị có phải đường đi? (Path Graph?)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đồ thị có phải đường đi? (Path Graph?)

Path Graph?

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a simple undirected graph with nn vertices and mm edges. It is a path graph if its vertices can be ordered as v1,v2,…,vnv_1,v_2,\ldots,v_n so that its edges are exactly (v1,v2),(v2,v3),…,(vn−1,vn)(v_1,v_2),(v_2,v_3),\ldots,(v_{n-1},v_n). Determine whether the given graph is a path graph.

Input

The first line contains two integers n,mn,m. Each of the next mm lines contains two integers u,vu,v, denoting an undirected edge. Vertices are numbered from 11 to nn.

Output

Print Yes if the graph is a path graph and No otherwise.

Subtasks

  • Subtask 1 (20 points): 2≤n≤1502\le n\le 150; 0≤m≤1700\le m\le 170; 1≤u,v≤n1\le u,v\le n; u≠vu\ne v; no repeated edges.
  • Subtask 2 (30 points): 2≤n≤100002\le n\le 10000; 0≤m≤60000\le m\le 6000; 1≤u,v≤n1\le u,v\le n; u≠vu\ne v; no repeated edges.
  • Subtask 3 (50 points): 2≤n≤2000002\le n\le 200000; 0≤m≤2000000\le m\le 200000; 1≤u,v≤n1\le u,v\le n; u≠vu\ne v; no repeated edges.

Examples

Input

4 3
1 3
4 2
3 2

Output

Yes

Explanation

The edges form the chain 1–3–2–4, with all vertices on one simple path.