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 n, m, t, cnt, S, N, M, l, r, mid, g[100005 * 4], dfn[100005 * 4],
    low[100005 * 4], d[100005 * 4], be[100005 * 4], co[100005], w[100005],
    ni[100005 * 4], f[100005 * 4];
int u[18 * 100005], v[18 * 100005], nex[18 * 100005];
bool inq[100005 * 4];
vector<int> G[100005];
struct edge {
  int u, v, c, t;
} E[100005];
void add(int x, int y) {
  ++M;
  u[M] = x;
  v[M] = y;
  nex[M] = g[x];
  g[x] = M;
  x ^= 1;
  y ^= 1;
  swap(x, y);
  ++M;
  u[M] = x;
  v[M] = y;
  nex[M] = g[x];
  g[x] = M;
}
void fly() {
  for (int i = 1; i <= t; ++i) {
    N += 2;
    add(d[i], N ^ 1);
    if (i != 1) add(N - 2 ^ 1, N ^ 1), add(N - 2 ^ 1, d[i] ^ 1);
  }
}
void dfs(int x) {
  dfn[x] = low[x] = ++cnt;
  d[++t] = x;
  inq[x] = 1;
  for (int i = g[x]; i; i = nex[i])
    if (!dfn[v[i]])
      dfs(v[i]), low[x] = min(low[x], low[v[i]]);
    else if (inq[v[i]])
      low[x] = min(low[x], dfn[v[i]]);
  if (low[x] == dfn[x]) {
    ++S;
    d[t + 1] = 0;
    while (d[t + 1] != x) {
      inq[d[t]] = 0;
      be[d[t]] = S;
      --t;
    }
  }
}
bool check(int mid) {
  for (int i = 2; i <= N; ++i) dfn[i] = low[i] = be[i] = g[i] = 0;
  int fl = 1;
  M = 0;
  N = m << 1 ^ 1;
  for (int i = 1; i <= n; ++i) {
    t = 0;
    for (int j = 0; j < G[i].size(); ++j) {
      d[++t] = G[i][j] << 1;
      int c = E[G[i][j]].c;
      if (w[c] == -1) {
        fl = 0;
        break;
      } else if (w[c]) {
        add(w[c] << 1, G[i][j] << 1 ^ 1);
        add(G[i][j] << 1 ^ 1, w[c] << 1);
        w[c] = -1;
      } else
        w[c] = G[i][j];
    }
    fly();
    for (int j = 0; j < G[i].size(); ++j) w[E[G[i][j]].c] = 0;
    if (!fl) return 0;
  }
  for (int i = 1; i <= m; ++i)
    if (E[i].t > mid) add(i << 1, i << 1 ^ 1);
  cnt = t = S = 0;
  for (int i = 2; i <= N; ++i)
    if (!dfn[i]) dfs(i);
  for (int i = 2; i <= N; ++i)
    if (be[i] == be[i ^ 1]) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &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);
    co[i] = E[i].c;
    G[E[i].u].push_back(i);
    G[E[i].v].push_back(i);
  }
  sort(co + 1, co + m + 1);
  t = unique(co + 1, co + m + 1) - co - 1;
  for (int i = 1; i <= m; ++i)
    E[i].c = lower_bound(co + 1, co + t + 1, E[i].c) - co;
  l = 0;
  r = 1000000001;
  while (l < r) {
    mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (l == 1000000001) {
    puts("No");
    return 0;
  }
  printf("Yes\n%d ", l);
  check(l);
  for (int i = 2; i <= N; ++i) ni[be[i]] = be[i ^ 1];
  for (int i = 1; i <= S; ++i)
    if (!f[i]) f[i] = 1, f[ni[i]] = -1;
  t = 0;
  for (int i = 1; i <= m; ++i)
    if (f[be[i << 1]] == 1) ++t;
  printf("%d\n", t);
  for (int i = 1; i <= m; ++i)
    if (f[be[i << 1]] == 1) printf("%d ", i);
  puts("");
  return 0;
}
