3 5
2 1 608591421 720962564
3 2 608591421 641991574
3 2 718110706 353409763
2 3 482786015 858341723
3 2 825397574 357507279
 2 1
2 1 317425595 636156322
 50000 1
20845 28516 904146168 997637433

Yes
641991574 1
2 
 Yes
0 0

 Yes
0 0


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define rep(i, a, b) for(register int i = a; i <= b; ++i)
#define go(u) for(int i = head[u], v = e[i].to; i; i = e[i].lst, v = e[i].to)
inline int gi() {
	int x = 0, f = 1;char ch = getchar();
	while(!isdigit(ch)){ if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)){ x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
	return x * f;
}
template<typename T>inline bool Max(T &a, T b) { return a < b ? a = b, 1 : 0;}
template<typename T>inline bool Min(T &a, T b) { return a > b ? a = b, 1 : 0;}
const int N = 6e5 + 7;
int n, m, edc, vc, ndc, scc_cnt, tim;
int u[N], v[N], c[N], V[N], low[N], pre[N], scc[N], head[N], t[N];
int st[N], tp;
struct edge {
	int lst, to, id;
	edge(){}edge(int lst, int to, int id):lst(lst), to(to), id(id){}
}e[N << 1];
void Add(int a, int b, int id) {
	e[++edc] = edge(head[a], b, id), head[a] = edc;
	e[++edc] = edge(head[b], a, id), head[b] = edc;
}
vector<int>G[N];
void lim(int a, int b) {
	G[a].pb(b);
	G[b ^ 1].pb(a ^ 1);
}
bool cmp(int a, int b) {
	return c[a] < c[b];
}
int Tarjan(int u) {
	low[u] = pre[u] = ++tim, st[++tp] = u;
	for(int i = 0; i < G[u].size(); ++i) {
		int v = G[u][i];
		if(!low[v]) {
			Tarjan(v);
			Min(pre[u], pre[v]);
		}else if(!scc[v]) Min(pre[u], low[v]);
	}
	if(low[u] == pre[u] && ++scc_cnt)
	for(int x = -1; x != u;)
	scc[x = st[tp--]] = scc_cnt;
}
int B(int x) { return x << 1;}
int A(int x) { return x << 1 | 1;}
bool check(int mid) {
	rep(i, 1, A(ndc)) G[i].clear();
	ndc = n;
	rep(u, 1, n) {
		int tp = 0;
		go(u) st[++tp] = e[i].id;
		sort(st + 1, st + 1 + tp, cmp);
		rep(i, 1, tp) {
			++ndc;
			if(i ^ 1) lim(A(ndc), A(ndc - 1));
			if(i ^ 1) lim(A(st[i]), A(ndc - 1));
			lim(A(st[i]), B(ndc));
			if(t[st[i]] > mid) G[A(st[i])].pb(B(st[i]));
		}
		for(int i = 1, j = 1; i <= tp; i = j + 1, j = i) {
			while(j + 1 <= tp && c[st[j + 1]] == c[st[j]]) ++j;
			rep(k, i, j) {
				++ndc;
				if(k ^ i) lim(A(ndc), A(ndc - 1));
				if(k ^ i) lim(B(st[k]), A(ndc - 1));
				lim(B(st[k]), B(ndc));
			}
		}
	}
	tp = tim = scc_cnt = 0;
	memset(low, 0, sizeof low);
	memset(pre, 0, sizeof pre);
	memset(scc, 0, sizeof scc);
	rep(i, 1, A(ndc)) if(!scc[i]) Tarjan(i);
	rep(i, 1, ndc) if(scc[A(i)] == scc[B(i)]) return 0;
	return 1;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("data.in", "r", stdin);
//	freopen("data.out", "w", stdout);
#endif
	n = gi(), m = gi();
	rep(i, 1, m) {
		u[i] = gi(), v[i] = gi(), c[i] = gi(), t[i] = gi();
		Add(u[i], v[i], i);
		V[i] = t[i];
	}
	V[vc = m + 1] = 0;
	sort(V + 1, V + 1 + vc);
	vc = unique(V + 1, V + 1 + vc) - V - 1;
	int l = 1, r = vc;
	while(l < r) {
		int mid = l + r >> 1;
		if(check(V[mid])) r = mid;
		else l = mid + 1;
	}
    if(!check(V[l])) return puts("No"), 0;
	puts("Yes");
	int ans = 0;
	rep(i, 1, m) if(scc[A(i)] < scc[B(i)]) ++ans;
	printf("%d %d\n", V[l], ans);
	for(int i = 1, cnt = 0; i <= m; ++i) if(scc[A(i)] < scc[B(i)]) {
	    ++cnt;
	    printf("%d%c", i, cnt == ans ? '\n':' ');
	}
	return 0;
}
