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>
const int N = 300000 + 7;
int n, m;
int u[N], v[N], c[N], t[N];
std::vector<int> e[N], pck[N];
int ban[N];
std::vector<int> g[N];
int dfn[N], low[N], idfn, sig[N], isig;
void tarjan(int s) {
  static int sta[N], top, ins[N];
  dfn[s] = low[s] = ++idfn;
  ins[sta[++top] = s] = 1;
  for (auto t : g[s])
    if (!dfn[t])
      tarjan(t), low[s] = std::min(low[s], low[t]);
    else if (ins[t])
      low[s] = std::min(low[s], dfn[t]);
  if (dfn[s] != low[s]) return;
  ++isig;
  while (sta[top + 1] != s) sig[sta[top]] = isig, ins[sta[top--]] = 0;
}
int check(int x) {
  for (int i = 1; i <= 6 * m; ++i) g[i].clear();
  for (int i = 1; i <= m; ++i)
    if (ban[i] || t[i] > x) g[i].push_back(m + i);
  for (int i = 1; i <= n; ++i)
    if (pck[i].size())
      g[pck[i][0] + m].push_back(pck[i][1]),
          g[pck[i][1] + m].push_back(pck[i][0]);
  for (int i = 1; i <= n; ++i) {
    auto get = [&](int s, int e, int t) {
      return e + 2 * m + (s == u[e] ? 0 : 2 * m) + t * m;
    };
    for (int j = 1; j < e[i].size(); ++j)
      g[get(i, e[i][j - 1], 0)].push_back(get(i, e[i][j], 0)),
          g[get(i, e[i][j], 1)].push_back(get(i, e[i][j - 1], 1));
    for (int j = 1; j < e[i].size(); ++j)
      g[e[i][j - 1]].push_back(get(i, e[i][j], 0)),
          g[e[i][j]].push_back(get(i, e[i][j - 1], 1));
  }
  for (int i = 1; i <= m; ++i)
    g[2 * m + i].push_back(m + i), g[3 * m + i].push_back(m + i),
        g[4 * m + i].push_back(m + i), g[5 * m + i].push_back(m + i);
  std::fill(dfn + 1, dfn + 6 * m + 1, 0);
  std::fill(low + 1, low + 6 * m + 1, 0);
  std::fill(sig + 1, sig + 6 * m + 1, 0);
  idfn = isig = 0;
  for (int i = 1; i <= 6 * m; ++i)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; ++i)
    if (sig[i] == sig[m + i]) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i)
    scanf("%d%d%d%d", u + i, v + i, c + i, t + i), e[u[i]].push_back(i),
        e[v[i]].push_back(i);
  for (int i = 1; i <= n; ++i) {
    std::sort(e[i].begin(), e[i].end(),
              [](int a, int b) { return c[a] < c[b]; });
    int l = 0, q = -1;
    for (int j = 1; j < e[i].size(); ++j)
      if (c[e[i][j - 1]] == c[e[i][j]]) ++l, q = c[e[i][j]];
    if (l > 1) return printf("No\n"), 0;
    if (l == 0) continue;
    for (auto j : e[i])
      if (c[j] != q)
        ban[j] = 1;
      else
        pck[i].push_back(j);
  }
  int l = 0, r = 1000000001;
  for (int m; l < r;) check(m = l + r >> 1) ? (r = m) : (l = m + 1);
  if (r == 1000000001) return printf("No\n"), 0;
  check(r);
  l = 0;
  for (int i = 1; i <= m; ++i) l += sig[i] < sig[m + i];
  printf("Yes\n%d %d\n", r, l);
  for (int i = 1; i <= m; ++i)
    if (sig[i] < sig[m + i]) printf("%d ", i);
  return 0;
}
