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 + 10;
struct Edge {
  int u, v, c, t;
} e[N];
int n, m, cnt, l, r, dfn[N * 10], low[N * 10], c[N * 10], sta[N * 10],
    ins[N * 10], top, cur, col;
vector<int> G[N], g[N * 10], A;
void B(vector<int> &v, int flag) {
  int S, T;
  for (auto i : v) {
    int x = i, y = i + m, t = ++cnt, s = ++cnt;
    if (!flag) {
      g[x].push_back(t), g[s].push_back(y);
      if (i != v[0])
        g[T].push_back(t), g[s].push_back(S), g[x].push_back(S),
            g[T].push_back(y);
    } else {
      g[t].push_back(x), g[y].push_back(s);
      if (i != v[0])
        g[t].push_back(T), g[S].push_back(s), g[S].push_back(x),
            g[y].push_back(T);
    }
    S = s, T = t;
  }
}
void tarjan(int x) {
  dfn[x] = low[x] = ++cur, ins[sta[++top] = x] = 1;
  for (auto i : g[x]) {
    if (!dfn[i])
      tarjan(i), low[x] = min(low[x], low[i]);
    else if (ins[i])
      low[x] = min(low[x], dfn[i]);
  }
  if (low[x] == dfn[x]) {
    c[x] = ++col;
    while (sta[top] != x) c[sta[top]] = col, ins[sta[top--]] = 0;
    ins[sta[top--]] = 0;
  }
}
int C(int v) {
  for (int i = 1; i <= m; i++)
    if (e[i].t > v) g[i].push_back(i + m);
  for (int i = 1; i <= cnt; i++) dfn[i] = low[i] = c[i] = 0;
  cur = top = col = 0;
  for (int i = 1; i <= cnt; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (e[i].t > v) g[i].pop_back();
  for (int i = 1; i <= m; i++)
    if (c[i] == c[i + m]) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m), cnt = 2 * m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d", &e[i].u, &e[i].v, &e[i].c, &e[i].t);
    G[e[i].u].push_back(i), G[e[i].v].push_back(i), r = max(r, e[i].t);
  }
  for (int i = 1; i <= n; i++) {
    sort(G[i].begin(), G[i].end(),
         [&](int A, int B) { return e[A].c < e[B].c; });
    vector<int> s;
    B(G[i], 0);
    for (int j = 0; j < G[i].size(); j++) {
      s.push_back(G[i][j]);
      while (j < G[i].size() - 1 && e[G[i][j]].c == e[G[i][j + 1]].c)
        s.push_back(G[i][++j]);
      B(s, 1), s.clear();
    }
  }
  if (!C(r)) return puts("No"), 0;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (C(mid))
      r = mid;
    else
      l = mid + 1;
  }
  C(l), puts("Yes");
  for (int i = 1; i <= m; i++)
    if (c[i] < c[i + m]) A.push_back(i);
  printf("%d %d\n", l, A.size());
  for (auto i : A) printf("%d ", i);
  puts("\n");
  return 0;
}
