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<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib> 
#include<vector>
#include<map>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; ++i)
#define dow(i,j,k) for(register int i = j; i >= k; --i)
#define ll long long
#define mp make_pair
#define fi first
#define se second 
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
 
inline int read() { 
    int s = 0, t = 1; char c = getchar();
    while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
    while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
    return s * t;
}

const int M = 2e5+5, inf = 1e9+7;
int n, m, pre, sz, l = 0, r = 0, mid, y, u[M], v[M], c[M], t[M], num[M], tot, cnt, q[M]; bool vis[M], mrk[M];
vector<int> e1[M], e2[M], e[M];
inline bool cmp(const int&a,const int&b) { return c[a] < c[b]; }
inline void add(int x,int y) { 
	e1[x].push_back(y);
	e2[y].push_back(x);
	
	e1[y^1].push_back(x^1);
	e2[x^1].push_back(y^1); 
}
inline void dfs1(int x) { 
	mrk[x] = 1;
	for(vector<int>::iterator it = e1[x].begin(); it != e1[x].end(); it++) if( !mrk[*it] ) dfs1(*it);
	q[++q[0]] = x;
}
inline void dfs2(int x,int col) { 
	num[x] = col;
	for(vector<int>::iterator it = e2[x].begin(); it != e2[x].end(); it++) if( !num[*it] ) dfs2(*it,col);
}
inline bool check(int x) { 
//	cout<<"W "<<x<<endl;
	rep(i,0,tot-1) e1[i].clear(), e2[i].clear(), num[i] = vis[i] = mrk[i] = 0;  
	tot = m;
	rep(i,1,n) { 
//		cout<<"A "<<i<<endl;
		pre = -1, sz = e[i].size();
		for(register int j = 0; j < sz; j++) { 
			y = e[i][j];
			if( pre == -1 ) pre = y;
			else add(pre<<1,y<<1|1), add(pre<<1,tot<<1), add(y<<1,tot<<1), pre = tot++;
			
			if( j >= 1 && c[e[i][j]] == c[e[i][j-1]] ) { 
				if( j >= 2 && c[e[i][j-1]] == c[e[i][j-2]] ) return 0;
				add(e[i][j]<<1|1,e[i][j-1]<<1);
			}
		}
	}
//	cout<<"A "<<endl;
	rep(i,0,m-1) if( t[i] > x ) e1[i<<1].push_back(i<<1|1), e2[i<<1|1].push_back(i<<1);
	tot <<= 1, cnt = q[0] = 0;
	rep(i,0,tot-1) if( !mrk[i] ) dfs1(i);
	dow(i,tot-1,0) if( !num[q[i]] ) dfs2(q[i],++cnt);
	for(register int i = 0; i < tot; i += 2) { 
		if( num[i] == num[i^1] ) return 0;
		if( num[i] > num[i^1] ) vis[i>>1] = 1; 
	} return 1;
}

int main() {
	n = read(), m = read();
	rep(i,0,m-1) u[i] = read(), v[i] = read(), c[i] = read(), t[i] = read(), e[u[i]].push_back(i), e[v[i]].push_back(i), r = max(r,t[i]);
	rep(i,1,n) sort(e[i].begin(),e[i].end(),cmp);
	while( l < r ) { 
		mid = (l + r) >> 1;
		if( check(mid) ) r = mid;
		else l = mid + 1;
	}
	if( !check(l) ) puts("No");
	else { 
		puts("Yes"), tot = 0;
		rep(i,0,m-1) if( vis[i] ) tot++;
		printf("%d %d\n", l, tot);
		rep(i,0,m-1) if( vis[i] ) printf("%d ", i+1); puts("");
	}
	return 0;
}