Codeforces Round 326 (Div. 2)
F
Duff in Mafia
Codeforces
未评级
原题
← E→
翻译中…

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 $*v*_{*i*}$ and $*u*_{*i*}$ and its color is $*c*_{*i*}$ and its destructing time is $*t*_{*i*}$.

翻译中…

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.

翻译中…

image

翻译中…

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 × 10^{4}$ and $1 ≤ *m* ≤ 5 × 10^{4}$), 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 $*v*_{*i*}, *u*_{*i*}, *c*_{*i*}$ and $*t*_{*i*}$ ($1 ≤ *v*_{*i*}, *u*_{*i*} ≤ *n*$, $*v*_{*i*} ≠ *u*_{*i*}$ and $1 ≤ *c*_{*i*}, *t*_{*i*} ≤ 10^{9}$ 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 (image).

翻译中…

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.

翻译中…

Note

翻译中…

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

翻译中…

image

翻译中…

A solution would be to destruct the roads with crosses.

翻译中…

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

翻译中…

image

翻译中…

样例

Input #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
Output #1
Yes
3 2
4 5
InputCopy OutputCopy
Input #2
3 5
3 2 1 3
1 3 1 1
3 2 1 4
1 3 2 2
1 3 2 10
Output #2
No
InputCopy OutputCopy
题目信息
题号
588F
时间限制
6 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。