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;
std::mt19937 rnd(time(0));
inline int sj(int n) {
  unsigned int x = rnd();
  return x % n + 1;
}
template <typename typC>
void read(register typC &x) {
  register int c = getchar(), fh = 1;
  while ((c < 48) || (c > 57)) {
    if (c == '-') {
      c = getchar();
      fh = -1;
      break;
    }
    c = getchar();
  }
  x = c ^ 48;
  c = getchar();
  while ((c >= 48) && (c <= 57)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  x *= fh;
}
template <typename typC>
void write(register typC x) {
  if (x < 0) putchar('-'), x = -x;
  static int st[100];
  register int tp = 1;
  register typC y;
  st[1] = x % 10;
  x /= 10;
  while (x) y = x / 10, st[++tp] = x - y * 10, x = y;
  ++tp;
  while (--tp) putchar(st[tp] | 48);
}
template <typename typC>
void write(register typC *a, register int num) {
  for (register int i = 1; i <= num; i++)
    write(a[i]), putchar(i == num ? 10 : 32);
}
const int N = 1e6 + 2, M = 1e6 + 2, p = 998244353;
inline void inc(register int &x, const int y) {
  if ((x += y) >= p) x -= p;
}
inline void dec(register int &x, const int y) {
  if ((x -= y) < 0) x += p;
}
inline int ksm(register int x, register int y) {
  register int r = 1;
  while (y) {
    if (y & 1) r = (long long)r * x % p;
    x = (long long)x * x % p;
    y >>= 1;
  }
  return r;
}
struct P {
  int v, w, c, wz;
  P(int a = 0, int b = 0, int C = 0, int d = 0) : v(a), w(b), c(C), wz(d) {}
  bool operator<(const P &o) const { return c < o.c; }
};
struct Q {
  int u, v, w, c, wz;
  bool operator<(const Q &o) const { return w < o.w; }
};
Q lb[N];
P b[N];
int ans[N];
vector<int> lj[M], ylj[M];
vector<P> bel[N];
int dfn[M], low[M], st[M], fa[M];
int T, n, m, c, i, j, k, x, y, z, la, l, r, mid, tp, cnt, fs, ds;
bool ed[M];
void dfs(int x) {
  dfn[x] = low[x] = ++cnt;
  ed[st[++tp] = x] = 1;
  for (auto v : lj[x])
    if (!dfn[v])
      dfs(v), low[x] = min(low[x], low[v]);
    else if (ed[v])
      low[x] = min(low[x], dfn[v]);
  if (dfn[x] == low[x]) {
    ++fs;
    while (st[tp + 1] != x) {
      fa[st[tp]] = fs;
      ed[st[tp--]] = 0;
    }
  }
}
bool pd(int lim) {
  assert(tp == 0);
  for (i = 1; i <= m << 1; i++)
    lj[i].clear(), lj[i].resize(ylj[i].size()),
        memcpy(&lj[i][0], &ylj[i][0], ylj[i].size() << 2);
  memset(dfn + 1, 0, ds << 2);
  cnt = fs = 0;
  for (i = lim + 1; i <= m; i++) lj[lb[i].wz + m].push_back(lb[i].wz);
  for (i = 1; i <= ds; i++)
    if (!dfn[i]) dfs(i);
  for (i = 1; i <= m; i++)
    if (fa[i] == fa[i + m]) return 0;
  return 1;
}
int main() {
  read(n);
  read(m);
  for (i = 1; i <= m; i++)
    read(lb[i].u), read(lb[i].v), read(lb[i].c), read(lb[i].w), lb[i].wz = i;
  sort(lb + 1, lb + m + 1);
  for (i = 1; i <= m; i++)
    bel[lb[i].u].push_back(P(lb[i].v, lb[i].w, lb[i].c, lb[i].wz)),
        bel[lb[i].v].push_back(P(lb[i].u, lb[i].w, lb[i].c, lb[i].wz));
  ds = m << 1;
  for (i = 1; i <= n; i++)
    if (bel[i].size()) {
      sort(bel[i].begin(), bel[i].end());
      for (j = 0; j < bel[i].size(); j = k) {
        k = j + 1;
        while (k < bel[i].size() && bel[i][k].c == bel[i][j].c) ++k;
        if (k - j > 2) return puts("No"), 0;
        if (k == j + 2) {
          ylj[bel[i][j].wz].push_back(bel[i][j + 1].wz + m);
          ylj[bel[i][j + 1].wz + m].push_back(bel[i][j].wz);
          ylj[bel[i][j + 1].wz].push_back(bel[i][j].wz + m);
          ylj[bel[i][j].wz + m].push_back(bel[i][j + 1].wz);
        }
      }
      for (j = 0; j < bel[i].size(); j++)
        ylj[ds + j + 1].push_back(bel[i][j].wz);
      for (j = 1; j < bel[i].size(); j++) ylj[ds + j + 1].push_back(ds + j);
      ds += bel[i].size();
      for (j = 0; j < bel[i].size(); j++)
        ylj[ds + j + 1].push_back(bel[i][j].wz);
      for (j = 1; j < bel[i].size(); j++) ylj[ds + j].push_back(ds + j + 1);
      ds -= bel[i].size();
      for (j = 0; j < bel[i].size(); j++) {
        if (j) ylj[bel[i][j].wz + m].push_back(ds + j - 1);
        if (j + 1 < bel[i].size())
          ylj[bel[i][j].wz + m].push_back(ds + bel[i].size() + j + 1);
      }
      ds += bel[i].size() << 1;
    }
  l = 0;
  r = m;
  while (l < r) {
    mid = l + r >> 1;
    if (pd(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (pd(l)) {
    puts("Yes");
    cnt = 0;
    for (i = 1; i <= m; i++)
      if (fa[i] > fa[i + m]) ans[++cnt] = i;
    printf("%d %d\n", lb[l].w, cnt);
    for (i = 1; i <= cnt; i++) printf("%d%c", ans[i], i == cnt ? 10 : 32);
  } else
    puts("No");
}
