#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;
}
