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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx,avx2,fma")

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#ifdef LOCAL
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f (const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); }
#define dbg2(x, j, n) cout<< #x << " : "; output((j), (n), x, 1);
#else
#define dbg(...) 0
#define dbg2(x, j, n) 0
#endif
#define SZ(x) ((ll)((x).size()))
#define File(s, t) freopen(s ".txt", "r", stdin); freopen(t ".txt", "w", stdout);
#define input(j, n, a) for (int _i = (j); _i < (n)+(j); _i++) cin>> a[_i];
#define output(j, n, a, t) for (int _i = (j); _i < (n)+(j); _i++) cout<< a[_i] << (((t) && _i != (n)+(j)-1)? ' ' : '\n');
#define kill(x) return cout<< x << endl, 0
#define cl const ll
#define fr first
#define sc second
#define mid ((l + r) / 2)
#define All(x) (x).begin(), (x).end()

const long long inf = 1e18;
cl mod = 1e9 + 7, MOD = 998244353;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << '(' << a.first << ", " << a.second << ')';    }
template <class A> ostream& operator << (ostream& out, const vector<A> &a) {
	if(!a.size())return cout<<"[]";cout<< '[' << a[0]; for (int i = 0; ++i < (int)(a.size());) cout<< ", " << a[i];cout<< ']';  }
template <class T, typename _t = less <T> > using Tree = tree <T, null_type, _t, rb_tree_tag, tree_order_statistics_node_update>;

cl N = 2e5 + 6;

ll v [N], u [N], c [N], t [N], n, m, lst;
unordered_map <ll, ll> mp [N];
vector <ll> adj [N], in [N + N], out [N + N], tops, cmprs, ans;
vector <pll> bad;
ll scc [N + N], cnt, ct [N + N];
bool mark [N + N];

inline void addE (cl &x, cl &y) {
	out[x ^ 1].push_back(y);
	in[y].push_back(x ^ 1);
	out[y ^ 1].push_back(x);
	in[x].push_back(y ^ 1);
}

void dfs (ll v) {
	mark[v] = 1;
	for (auto &u : out[v])	if (!mark[u])	dfs(u);
	tops.push_back(v);
}

void sfd (ll v) {
	mark[v] = 1;
	scc[v] = cnt;
	for (auto &u : in[v])	if (!mark[u])	sfd(u);
}

bool check (ll x) {
	for (ll i = 0; i < N + N; i++)	in[i].clear(), out[i].clear();
	for (ll i = 0; i < m; i++)	if (t[i] > x)	addE(2 * i + 1, 2 * i + 1);
	for (auto &p : bad)	addE(2 * p.fr, 2 * p.sc);
	lst = 2 * m;
	for (ll i = 1; i <= n; i++) if (!adj[i].empty()) {
		ll j = adj[i][0];
		lst++;
		addE(2 * j + 1, 2 * lst);
		for (j = 1; j < SZ(adj[i]); j++) {
			addE(2 * lst + 1, 2 * (lst + 1));
			addE(2 * lst + 1, 2 * adj[i][j] + 1);
			lst++;
			addE(2 * adj[i][j] + 1, 2 * lst);
		}
	}

	tops.clear();
	memset(mark, 0, sizeof mark);
	for (ll i = 0; i < N + N; i++)	if (!mark[i])	dfs(i);
	reverse(All(tops));
	cnt = 0;
	memset(mark, 0, sizeof mark);
	for (auto &p : tops)	if (!mark[p])	cnt++, sfd(p);

	for (ll i = 0; i < N; i++)	if (scc[2 * i] == scc[2 * i + 1])	return 0;
	return true;
}

int main ()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	ll i, l, r;

	cin>> n >> m;
	for (i = 0; i < m; i++) {
		cin>> v[i] >> u[i] >> c[i] >> t[i];
		cmprs.push_back(t[i]);
		adj[v[i]].push_back(i);
		adj[u[i]].push_back(i);

		if (mp[v[i]].count(c[i])) {
			if (mp[v[i]][c[i]] == -1)	kill("No");
			bad.push_back({i, mp[v[i]][c[i]]});
			mp[v[i]][c[i]] = -1;
		}
		else mp[v[i]][c[i]] = i;

		if (mp[u[i]].count(c[i])) {
			if (mp[u[i]][c[i]] == -1)	kill("No");
			bad.push_back({i, mp[u[i]][c[i]]});
			mp[u[i]][c[i]] = -1;
		}
		else mp[u[i]][c[i]] = i;
	}

	for (i = 1; i <= n; i++) {
		r = 0;
		for (auto &p : mp[i]) if (p.sc == -1) {
			if(r)	kill("No");
			r = 1;
		}
	}

	cmprs.push_back(0);
	sort(All(cmprs)); cmprs.resize(unique(All(cmprs)) - cmprs.begin());

	l = -1, r = SZ(cmprs);
	while (r - l > 1) {
		// dbg(mid, check(cmprs[mid]));
		if (check(cmprs[mid]))	r = mid;
		else l = mid;
	}

	if (r == SZ(cmprs))	kill("No");

	if (!check(r))	kill("No");

	cout<< "Yes\n";
	for (i = 0; i < m; i++)	if (t[i] <= cmprs[r] && scc[2 * i] > scc[2 * i + 1])	ans.push_back(i + 1);

	cout<< cmprs[r] << ' ' << SZ(ans) << '\n';
	for (auto &p : ans)	cout<< p << ' ';

	cerr<< "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

	return 0;
}
/*
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

2 3
1 2 1 5
1 2 1 7
1 2 2 2

*/