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;
const int N = (5e4 + 3) * 3;
int n, m, vis[N << 1], c[N], t[N], bad[N][2], Time;
vector<int> adj[N << 1], rev_adj[N << 1], ord, comp, vec[N], ans;
void read_input() {
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v >> c[i] >> t[i];
    vec[--u].push_back(i);
    vec[--v].push_back(i);
  }
}
void print_no() {
  cout << "No" << endl;
  exit(0);
}
void prep() {
  memset(bad, -1, sizeof bad);
  for (int u = 0; u < n; u++) {
    unordered_map<int, int> cnt;
    int col = -1;
    for (int ind : vec[u]) {
      cnt[c[ind]]++;
      if (cnt[c[ind]] >= 2) {
        if (cnt[c[ind]] > 2 || col != -1) print_no();
        col = c[ind];
      }
    }
    if (col != -1)
      for (int ind : vec[u])
        if (c[ind] == col) (bad[u][0] == -1 ? bad[u][0] : bad[u][1]) = ind;
  }
}
void add_edge(int u, int v) {
  adj[u].push_back(v);
  rev_adj[v].push_back(u);
}
void add_clause(int x, int y) {
  add_edge(x ^ 1, y);
  add_edge(y ^ 1, x);
}
void dfs(int u, vector<int> *g, vector<int> &vec, int x = 1) {
  vis[u] = x;
  for (int v : g[u])
    if (vis[v] == 0) dfs(v, g, vec, x);
  vec.push_back(u);
}
void reset() {
  for (int u = 0; u < N << 1; u++) {
    adj[u].clear();
    rev_adj[u].clear();
  }
  comp.clear();
  ord.clear();
  memset(vis, 0, sizeof vis);
}
void make(int d) {
  for (int i = 0; i < n; i++)
    if (bad[i][0] != -1) add_clause(bad[i][0] << 1, bad[i][1] << 1);
  for (int u = 0; u < n; u++)
    for (int ind : vec[u])
      if (t[ind] > d) add_clause(ind << 1 | 1, ind << 1 | 1);
  int cnt = m;
  for (int u = 0; u < n; u++) {
    int sz = vec[u].size();
    for (int i = cnt; i < cnt + sz - 1; i++) add_clause(i << 1 | 1, i + 1 << 1);
    for (int i = cnt; i < cnt + sz - 1; i++)
      add_clause(vec[u][i - cnt] << 1 | 1, i + 1 << 1);
    for (int i = cnt; i < cnt + sz; i++)
      add_clause(i << 1 | 1, vec[u][i - cnt] << 1 | 1);
    cnt += sz;
  }
}
bool check(int d) {
  reset(), make(d);
  for (int u = 0; u < N << 1; u++)
    if (vis[u] == 0) dfs(u, adj, ord);
  int cnt = 0;
  reverse(ord.begin(), ord.end());
  memset(vis, 0, sizeof vis);
  for (int u : ord)
    if (vis[u] == 0) dfs(u, rev_adj, comp, ++cnt);
  for (int u = 0; u + 1 < N; u++)
    if (vis[u << 1] == vis[u << 1 | 1]) return false;
  return true;
}
void solve() {
  if (check(1e9) == false) print_no();
  int l = -1, r = 1e9;
  while (r - l > 1) {
    int mid = l + r >> 1;
    check(mid) ? r = mid : l = mid;
  }
  Time = r;
}
void write_output() {
  cout << "Yes" << endl;
  check(Time);
  for (int i = 0; i < m; i++)
    if (vis[i << 1] > vis[i << 1 | 1]) ans.push_back(i);
  cout << Time << ' ' << ans.size() << endl;
  for (int x : ans) cout << x + 1 << ' ';
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), prep(), solve(), write_output();
}
