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>
#define FT first
#define SC second
#define PB push_back
#define MP make_pair
#define REP(i, l, r) for(int i = (l); i <= (r); i++)
#define PER(i, r, l) for(int i = (r); i >= (l); i--)
#define DFOR(i, x) for(int i = hd[(x)]; i; i = e[i].nxt)
#define VEP(i, x) for(int i = 0; i < (x).size(); i++)
#define MEM(a) memset(a, 0, sizeof(a));

using namespace std;
typedef long long LL;
typedef long double LD;
const int inf = 1000000001;
const int MOD = 1000000007;
const int N = 50000 * 18, M = N * 8;
struct Edge{
	int x, y, nxt;
}e[M];
int hd[N], color[N], tail, m, d[N];
vector <int> rub;
vector <pair<int, int> > vec[N];
void addedge(int x, int y, int tx, int ty){
	e[++tail].x = tx, e[tail].y = ty, e[tail].nxt = hd[x << 1 | y], hd[x << 1 | y] = tail;
}
void add(int x, int y, int tx, int ty){
	addedge(x, y ^ 1, tx, ty), addedge(tx, ty ^ 1, x, y);
}
void clear(){
	VEP(i, rub) color[rub[i]] = -1;
	rub.clear();
}
bool setcolor(int x, int y){
	if (color[x] == y) return 0;
	if (color[x] == (y ^ 1)) return 1;
	color[x] = y, rub.PB(x);
	DFOR(i, (x << 1 | y)){
		int tx = e[i].x, ty = e[i].y;
		if (setcolor(tx, ty)) return 1;
	}
}
bool ok(int t){
	memset(color, -1, sizeof(color));
	rub.clear();
	REP(i, 1, m) if (d[i] > t && setcolor(i, 0)) return 0;
	REP(i, 1, m){
		if (color[i] != -1) continue;
		REP(j, 0, 1)
			if (setcolor(i, j)) clear();
			else {rub.clear(); break;}
		if (color[i] == -1) return 0;
	}
	return 1;
}
int main(){
	int n, x, y, c;
	scanf("%d%d", &n, &m);
	REP(i, 1, m){
		scanf("%d%d%d%d", &x, &y, &c, &d[i]);
		vec[x].PB(MP(c, i)), vec[y].PB(MP(c, i));
	}
	REP(i, 1, m) add(i, 1, m + i, 1), add(i, 0, m + m + i, 1);
	REP(i, 1, n){
		sort(vec[i].begin(), vec[i].end());
		VEP(j, vec[i]){
			int l = vec[i][j].SC;
			if (j){
				int r = vec[i][j - 1].SC;
				if (vec[i][j].FT == vec[i][j - 1].FT){
					add(m + r, 0, l, 1);
					add(m + r, 0, m + l, 1);
				}
				add(m + m + r, 0, l, 0);
				add(m + m + r, 0, m + m + l, 1);
			}
		}
	}
	int ll = 0, rr = inf;
	while (ll < rr){
		int mid = (ll + rr) >> 1;
		if (ok(mid)) rr = mid;
		else ll = mid + 1;
	}
	if (ok(ll)){
		puts("Yes");
		vector <int> ans;
		REP(i, 1, m) if (color[i] == 1) ans.PB(i);
		printf("%d %d\n", ll, ans.size());
		VEP(i, ans) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
	} else puts("No");
}
