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 = 50 * 1000 + 10;
int n, m, t[N], c[N];
vector<pair<int, int> > adj[N], es[2];
vector<int> edg, vec[2], bs;
vector<int> col[N];
set<int> bad;
bool part[N], cyc[N];
int mark[N], sum[2], seen[N];
int ans, num;
void dfs(int v, int c, int r, int ed) {
  mark[v] = c;
  num++;
  part[v] = r;
  int deg = 0;
  for (auto e : adj[v]) {
    int u = e.first, id = e.second;
    if (::c[id] != c) continue;
    deg++;
    if (seen[id]) continue;
    sum[r] = max(sum[r], t[id]);
    vec[r].push_back(id);
    es[r].push_back({u, v});
    seen[id] = 1;
    if (mark[u] == c) {
      if (part[v] == part[u]) {
        cout << "No\n";
        exit(0);
      }
    } else {
      dfs(u, c, 1 - r, id);
    }
  }
  if (deg == 1 && cyc[v]) bad.insert(part[v]), bs.push_back(v);
  return;
}
void dfs_all(int c) {
  for (int i = 0; i < n; i++) {
    if (mark[i] != c) {
      sum[0] = sum[1] = 0;
      num = 0;
      vec[0].clear();
      vec[1].clear();
      bad.clear();
      es[1].clear();
      es[0].clear();
      bs.clear();
      dfs(i, c, 0, -1);
      if (num == 1) {
        continue;
      }
      if (bad.size() == 2 && num % 2) {
        cout << "No\n";
        exit(0);
      }
      int b = 0;
      if (bad.empty()) {
        if (sum[0] > sum[1]) b = 1;
      } else {
        for (auto e : es[0]) {
          if (e.first == bs[0] || e.second == bs[0]) {
            b = 1;
            break;
          }
        }
      }
      ans = max(ans, sum[b]);
      for (auto p : vec[b]) edg.push_back(p + 1);
    }
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cin >> n >> m;
  vector<int> C;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v >> c[i] >> t[i];
    if (u == v) return cout << "No\n", 0;
    u--, v--;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
    col[u].push_back(c[i]), col[v].push_back(c[i]);
    C.push_back(c[i]);
  }
  for (int v = 0; v < n; v++) {
    sort(col[v].begin(), col[v].end());
    int cnt = 0, t = 0;
    for (int i = 0; i < (int)col[v].size(); i++) {
      if (i == 0) {
        cnt++;
        continue;
      }
      if (col[v][i] != col[v][i - 1]) {
        if (cnt == 2) t++;
        cnt = 1;
      } else {
        cnt++;
        if (cnt > 2) return cout << "No\n", 0;
      }
    }
    if (cnt == 2) t++;
    if (t > 1) return cout << "No\n", 0;
    if (t == 1) cyc[v] = 1;
  }
  sort(C.begin(), C.end());
  C.resize(distance(C.begin(), unique(C.begin(), C.end())));
  int mx = 0;
  for (int c : C) {
    dfs_all(c);
  }
  cout << "Yes\n";
  cout << ans << ' ' << edg.size() << '\n';
  for (auto e : edg) cout << e << ' ';
  return 0;
}
