Problem10304--CF EDU - DSU - Step 2 - F. Dense spanning tree

10304: CF EDU - DSU - Step 2 - F. Dense spanning tree

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You need to find a spanning tree in the graph so that the difference between the maximal and the minimal edges is minimal.

Input

The first line of the input contains two integers $n,m\ (2 ≤n≤ 1000,\ 0 ≤m≤ 10,000)$ — the number of vertices and the number of edges, respectively. 

Next $m$ lines contain the description of edges, one per line. Edge $i$ is described by three integers $b_i, e_i,w_i\ (1 ≤b_i,e_i≤n,\ - 10^9 ≤w_i≤ 10^9)$ — the ends of the edge and its weight, respectively.

Output

If the spanning tree exists, then the first line of the output should contain "YES", and the second line should contain one integer — the minimal difference between the maximal and the minimal edges of the spanning tree.

Otherwise, the sole line of the output should contain "NO".

Sample 1 Input

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

Sample 1 Output

YES
0

HINT

CF DSU.

Source/Category