Duff in Mafia

TimeLimit:6000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Duff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has n cities (numbered from 1 to n) connected by m bidirectional roads (numbered by 1 to m).

Each road has a destructing time, and a color. i-th road connects cities vi and ui and its color is ci and its destructing time is ti.

Mafia wants to destruct a matching in Andarz Gu. A matching is a subset of roads such that no two roads in this subset has common endpoint. They can destruct these roads in parallel, i. e. the total destruction time is a maximum over destruction times of all selected roads.

They want two conditions to be satisfied:

  1. The remaining roads form a proper coloring.
  2. Destructing time of this matching is minimized.

The remaining roads after destructing this matching form a proper coloring if and only if no two roads of the same color have same endpoint, or, in the other words, edges of each color should form a matching.

There is no programmer in Mafia. That's why Duff asked for your help. Please help her and determine which matching to destruct in order to satisfied those conditions (or state that this is not possible).

Input

The first line of input contains two integers n and m (2 ≤ n ≤ 5 × 104 and 1 ≤ m ≤ 5 × 104), number of cities and number of roads in the country.

The next m lines contain the the roads. i - th of them contains four integers vi, ui, ci and ti (1 ≤ vi, ui ≤ n, vi ≠ ui and 1 ≤ ci, ti ≤ 109 for each 1 ≤ i ≤ m).

Output

In the first line of input, print "Yes" (without quotes) if satisfying the first condition is possible and "No" (without quotes) otherwise.

If it is possible, then you have to print two integers t and k in the second line, the minimum destructing time and the number of roads in the matching ().

In the third line print k distinct integers separated by spaces, indices of the roads in the matching in any order. Roads are numbered starting from one in order of their appearance in the input.

If there's more than one solution, print any of them.

SampleInput 1
5 7
2 1 3 7
3 1 1 6
5 4 1 8
4 5 1 1
3 2 2 3
4 5 2 5
2 3 2 4
SampleOutput 1
Yes
3 2
4 5
SampleInput 2
3 5
3 2 1 3
1 3 1 1
3 2 1 4
1 3 2 2
1 3 2 10
SampleOutput 2
No
Note

Graph of Andarz Gu in the first sample case is as follows:

A solution would be to destruct the roads with crosses.

Graph of Andarz Gu in the second sample case is as follows:

Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数1
总提交量2
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: