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;
int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 3) + (c << 1) + (ch ^ 48);
  return w * c;
}
const int M = 4e5 + 10;
struct edge {
  int x, y, c, t, id;
  edge(int _x = 0, int _y = 0, int _c = 0, int _t = 0, int _id = 0) {
    x = _x;
    y = _y;
    c = _c;
    t = _t;
    id = _id;
  }
} a[M];
bool cmp(edge A, edge B) { return A.t < B.t; }
vector<int> col[M], v[M];
vector<int> e[M];
int cn, ep[M][3];
int scc, dfn[M], low[M], tt, bl[M];
bool in[M];
int s[M], tp;
void tarjin(int x) {
  dfn[x] = low[x] = ++tt;
  in[x] = 1;
  s[++tp] = x;
  for (int i = 0; i <= (int)e[x].size() - 1; ++i) {
    int y = e[x][i];
    if (!dfn[y])
      tarjin(y), low[x] = min(low[x], low[y]);
    else if (in[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    scc++;
    while (s[tp] != x) {
      bl[s[tp]] = scc;
      in[s[tp]] = 0;
      tp--;
    }
    bl[x] = scc;
    tp--;
    in[x] = 0;
  }
}
int n, m, o[M];
bool check(int k) {
  int ct = 2 * m;
  for (int i = 1; i <= 4 * m; ++i) e[i].clear();
  for (int i = k + 1; i <= m; ++i) e[i].push_back(i + m);
  for (int i = 1; i <= cn; ++i) {
    for (int j = 0; j <= (int)col[i].size() - 1; ++j) {
      int x = col[i][j], u = a[x].x, v = a[x].y;
      if (++ep[u][0] >= 3) return 0;
      if (++ep[v][0] >= 3) return 0;
      ep[u][ep[u][0]] = x;
      ep[v][ep[v][0]] = x;
      if (ep[u][0] == 2) {
        e[ep[u][1] + m].push_back(ep[u][2]);
        e[ep[u][2] + m].push_back(ep[u][1]);
      }
    }
    for (int j = 0; j <= (int)col[i].size() - 1; ++j) {
      int x = col[i][j];
      ep[a[x].x][0] = ep[a[x].y][0] = 0;
    }
  }
  for (int i = 1; i <= 2; ++i) {
    vector<int> t;
    for (int j = 0; j <= (int)v[i].size() - 1; ++j) {
      int x = v[i][j];
      if (x > k) continue;
      t.push_back(x);
    }
    for (int j = 0; j <= (int)t.size() - 1; ++j) {
      int x = t[j];
      ++ct;
      e[ct].push_back(x + m);
      if (j) e[ct].push_back(ct - 2);
      ++ct;
      e[ct].push_back(x + m);
      if (j) e[ct - 2].push_back(ct);
      if (j) e[x].push_back(ct - 3);
      if (j != (int)t.size() - 1) e[x].push_back(ct + 2);
    }
  }
  memset(in, 0, sizeof in);
  memset(dfn, 0, sizeof dfn);
  tt = 0;
  tp = 0;
  scc = 0;
  for (int i = 1; i <= ct; ++i)
    if (!dfn[i]) tarjin(i);
  for (int i = 1; i <= m; ++i) {
    if (bl[i] == bl[i + m]) return 0;
  }
  return 1;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read(), c = read(), t = read();
    a[i] = edge(x, y, c, t, i);
    o[i] = c;
  }
  sort(o + 1, o + m + 1);
  cn = unique(o + 1, o + m + 1) - o - 1;
  for (int i = 1; i <= m; ++i)
    a[i].c = lower_bound(o + 1, o + cn + 1, a[i].c) - o;
  sort(a + 1, a + m + 1, cmp);
  for (int i = 1; i <= m; ++i) {
    v[a[i].x].push_back(i);
    v[a[i].y].push_back(i);
    col[a[i].c].push_back(i);
  }
  int l = 0, r = m, ans = -1;
  while (l <= r) {
    int mid = (l + r >> 1);
    if (check(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  if (ans != -1 && check(ans)) {
    int ct = 0;
    for (int i = 1; i <= m; ++i)
      if (bl[i] < bl[i + m]) ct++;
    cout << "Yes\n" << a[ans].t << " " << ct << "\n";
    for (int i = 1; i <= m; ++i)
      if (bl[i] < bl[i + m]) cout << a[i].id << " ";
  } else
    cout << "No\n";
  return 0;
}
