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 = 5e5 + 10;
int n, m;
pair<int, int> key[N];
int tim[N], fx[N];
map<int, int> cnt[N];
vector<int> to[N], nto[N];
vector<int> ori[N];
void link(int x, int y) { to[x].push_back(y); }
int zz;
void add(int u, int c, int i) {
  if (cnt[u][c] != 0) {
    if (cnt[u][c] == -1) {
      printf("No\n");
      exit(0);
    }
    link(i + m, cnt[u][c]);
    link(cnt[u][c] + m, i);
    cnt[u][c] = -1;
  } else {
    cnt[u][c] = i;
  }
}
int dfn[N], low[N], stm;
int S[N], ins[N], cir[N], tot;
vector<int> ps[N];
void tarjan(int x) {
  dfn[x] = low[x] = ++stm;
  S[++S[0]] = x;
  ins[x] = 1;
  for (int y : to[x]) {
    if (dfn[y]) {
      if (ins[y]) low[x] = min(low[x], low[y]);
    } else {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    }
  }
  if (low[x] == dfn[x]) {
    do {
      ins[S[S[0]]] = 0;
      cir[S[S[0]]] = x;
      if (S[S[0]] <= 2 * m) ps[x].push_back(S[S[0]]);
    } while (S[S[0]--] != x);
  }
}
int d[N], Q[N];
vector<int> es[N];
void topo() {
  int h = 0, t = 0;
  for (int i = 1; i <= tot; i++)
    if (cir[i] == i && d[i] == 0) Q[++t] = i;
  while (h < t) {
    int x = Q[++h];
    for (int y : nto[x]) {
      if (--d[y] == 0) Q[++t] = y;
    }
  }
  Q[0] = h;
}
int vis[N];
bool disable(int x) {
  if (vis[x] == 1) return 0;
  if (vis[x] == -1) return 1;
  vis[x] = -1;
  for (int e : ps[x]) {
    if (vis[cir[fx[e]]] == -1) return 0;
  }
  for (int y : nto[x])
    if (!disable(y)) return 0;
  return 1;
}
bool ok(int x) {
  memset(cir, 0, sizeof cir);
  memset(dfn, 0, sizeof dfn);
  memset(vis, 0, sizeof vis);
  memset(d, 0, sizeof d);
  memset(low, 0, sizeof low);
  for (int i = 1; i <= tot; i++) {
    ps[i].clear();
    to[i] = ori[i];
  }
  stm = 0;
  for (int i = 1; i <= m; i++)
    if (tim[i] > x) {
      link(i, i + m);
    }
  for (int i = 1; i <= tot; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++) {
    fx[i] = i + m;
    fx[i + m] = i;
    if (cir[i] == cir[i + m]) {
      return 0;
    }
  }
  for (int i = 1; i <= tot; i++) nto[i].clear();
  for (int x = 1; x <= tot; x++) {
    for (int y : to[x])
      if (cir[x] != cir[y]) {
        nto[cir[y]].push_back(cir[x]);
        d[cir[x]]++;
      }
  }
  topo();
  for (int i = 1; i <= Q[0]; i++) {
    int x = Q[i];
    if (x > 2 * m) {
      if (ps[x].size() == 0) continue;
      x = ps[x].back();
    }
    if (vis[cir[x]] == 0) {
      vis[cir[x]] = 1;
      vis[cir[fx[x]]] = -1;
    }
  }
  return 1;
}
int main() {
  cin >> n >> m;
  tot = 2 * m;
  for (int i = 1; i <= m; i++) {
    int u, v, c, t;
    scanf("%d %d %d %d", &u, &v, &c, &t);
    tim[i] = t;
    es[u].push_back(i);
    es[v].push_back(i);
    add(u, c, i);
    add(v, c, i);
  }
  for (int i = 1; i <= n; i++) {
    int pre = 0;
    for (int j : es[i]) {
      int u = ++tot;
      if (pre) {
        link(j, pre);
        link(u, pre);
      }
      link(u, j + m);
      pre = u;
    }
    pre = 0;
    for (int z = es[i].size() - 1; ~z; z--) {
      int j = es[i][z];
      int u = ++tot;
      if (pre) {
        link(j, pre);
        link(u, pre);
      }
      link(u, j + m);
      pre = u;
    }
  }
  for (int i = 1; i <= tot; i++) ori[i] = to[i];
  int l = 0, r = 1e9, ans = 0;
  while (l <= r) {
    if (ok(l + r >> 1)) {
      ans = r = l + r >> 1;
      r--;
    } else {
      l = (l + r >> 1) + 1;
    }
  }
  if (!ok(ans)) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  int cnt = 0;
  for (int i = 1; i <= m; i++)
    if (vis[cir[i]] == 1) {
      cnt++;
    }
  cout << ans << " " << cnt << endl;
  for (int i = 1; i <= m; i++)
    if (vis[cir[i]] == 1) {
      printf("%d ", i);
    }
}
