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 ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
const int N = 5e4 + 1;
int n, m, c[N], t[N];
bool mark[4 * N];
vector<pair<int, int> > edge;
vector<int> ed[N], a[4 * N];
vector<int> res, st;
inline void add(int x1, int x2) {
  a[x1 ^ 1].push_back(x2);
  a[x2 ^ 1].push_back(x1);
}
bool dfs(int u, int val) {
  if (mark[u ^ 1]) return 0;
  if (mark[u]) return 1;
  if (u % 2 == 0 && u < 2 * m && t[u >> 1] > val) return 0;
  mark[u] = 1;
  st.push_back(u);
  for (int v : a[u])
    if (!dfs(v, val)) return 0;
  return 1;
}
bool ok(int val) {
  fill(mark, mark + 4 * m, 0);
  for (int i = (0); i <= (4 * m - 1); ++i) {
    if (!mark[i] && !mark[i + 1]) {
      st.clear();
      if (!dfs(i, val)) {
        for (int v : st) mark[v] = 0;
        st.clear();
        if (!dfs(i + 1, val)) return 0;
      }
    }
    i++;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = (0); i <= (m - 1); ++i) {
    int u, v;
    cin >> u >> v >> c[i] >> t[i];
    ed[u].push_back(i);
    ed[v].push_back(i);
    edge.push_back({u, v});
  }
  for (int i = (1); i <= (n); ++i)
    if (((int)(ed[i]).size())) {
      sort((ed[i]).begin(), (ed[i]).end(),
           [&](const int& e1, const int& e2) { return c[e1] < c[e2]; });
      for (int j = (0); j <= (((int)(ed[i]).size()) - 1); ++j) {
        int k = j;
        while (k < ((int)(ed[i]).size()) - 1 && c[ed[i][k]] == c[ed[i][k + 1]])
          k++;
        if (k - j > 1) {
          cout << "No";
          return 0;
        }
        if (k - j == 1) add(ed[i][j] << 1, ed[i][k] << 1), j++;
      }
      for (int j = (0); j <= (((int)(ed[i]).size()) - 1); ++j) {
        int xi = ed[i][j] << 1;
        add(xi ^ 1, 2 * m + xi);
        if (j == ((int)(ed[i]).size()) - 1) break;
        add(2 * m + xi + 1, 2 * m + ed[i][j + 1] << 1);
        add(2 * m + xi + 1, (ed[i][j + 1] << 1) | 1);
      }
    }
  int l = 0, r = 1e9;
  while (l <= r) {
    int mi = (l + r) >> 1;
    if (ok(mi))
      r = mi - 1;
    else
      l = mi + 1;
  }
  if (l == 1e9 + 1)
    cout << "No\n";
  else {
    ok(l);
    for (int i = (0); i <= (2 * m - 1); ++i) {
      if (mark[i]) res.push_back(i / 2 + 1);
      i++;
    }
    cout << "Yes\n" << l << ' ' << ((int)(res).size()) << '\n';
    for (int v : res) cout << v << ' ';
  }
  return 0;
}
