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 = 100100;
vector<int> ch[N];
int to[N], col[N], len[N], e = 1;
void addedge(int t, int v, int c, int s) {
  e++, to[e] = v, col[e] = c, len[e] = s, ch[t].push_back(e);
  e++, to[e] = t, col[e] = c, len[e] = s, ch[v].push_back(e);
}
bool cmp(int x, int y) { return col[x] < col[y]; }
int mid;
namespace TwoSat {
int mark[N];
vector<int> q;
bool dfs(int u) {
  if (mark[u]) return 1;
  if (mark[u ^ 1]) {
    while (!q.empty()) {
      mark[q.back()] = 0;
      q.pop_back();
    }
    return 0;
  }
  mark[u] = 1;
  q.push_back(u);
  if (u & 1) {
    int k = to[u];
    auto l = lower_bound(ch[k].begin(), ch[k].end(), u, cmp);
    for (auto ii = l; ii != ch[k].end() && col[*ii] == col[u]; ii++) {
      int i = *ii;
      if (i != u && i != (u ^ 1))
        if (len[i] > mid || !dfs(min(i, i ^ 1))) {
          while (!q.empty()) {
            mark[q.back()] = 0;
            q.pop_back();
          }
          return 0;
        }
    }
    k = to[u ^ 1];
    l = lower_bound(ch[k].begin(), ch[k].end(), u, cmp);
    for (auto ii = l; ii != ch[k].end() && col[*ii] == col[u]; ii++) {
      int i = *ii;
      if (i != u && i != (u ^ 1))
        if (len[i] > mid || !dfs(min(i, i ^ 1))) {
          while (!q.empty()) {
            mark[q.back()] = 0;
            q.pop_back();
          }
          return 0;
        }
    }
  } else {
    int k = to[u];
    for (auto i : ch[k])
      if (i != u && i != (u ^ 1))
        if (!dfs(max(i, i ^ 1))) return 0;
    k = to[u ^ 1];
    for (auto i : ch[k])
      if (i != u && i != (u ^ 1))
        if (!dfs(max(i, i ^ 1))) return 0;
  }
  return 1;
}
bool solve(int n) {
  memset(mark, 0, sizeof(mark));
  for (int i = 2; i <= n * 2; i += 2)
    if (!mark[i] && !mark[i ^ 1]) {
      q.clear();
      if (len[i] > mid && !dfs(i ^ 1)) return 0;
      if (!dfs(i ^ 1) && !dfs(i)) return 0;
    }
  return 1;
}
}  // namespace TwoSat
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int t, v, c, s;
    scanf("%d%d%d%d", &t, &v, &c, &s);
    addedge(t, v, c, s);
  }
  for (int i = 1; i <= n; i++) {
    sort(ch[i].begin(), ch[i].end(), cmp);
  }
  int l = -1, r = 1000000007;
  while (l != r - 1) {
    mid = (l + r) >> 1;
    if (TwoSat::solve(m))
      r = mid;
    else
      l = mid;
  }
  if (r == 1000000007) {
    puts("No");
  } else {
    puts("Yes");
    mid = r;
    TwoSat::solve(m);
    int ans = 0;
    for (int i = 1; i <= m; i++)
      if (TwoSat::mark[i << 1]) ans++;
    printf("%d %d\n", r, ans);
    for (int i = 1; i <= m; i++)
      if (TwoSat::mark[i << 1]) printf("%d ", i);
  }
  return 0;
}
