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();
int n, m, idcnt;
vector<int> p[200005];
struct E {
  int u, v, c, w, id;
  void init() {
    u = read(), v = read(), c = read(), w = read();
    p[u].push_back(id), p[v].push_back(id);
  }
} e[200005];
bool cmp(int x, int y) { return e[x].c < e[y].c; }
int hd[400005], nx[1000006], to[1000006], cnt;
void add(int f, int t) { nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t; }
int pre[400005], low[400005], dfn;
int st[400005], top, inst[400005];
int scc_id[400005], scc_cnt;
void dfs(int u) {
  pre[u] = low[u] = ++dfn, st[++top] = u, inst[u] = 1;
  for (int i = hd[u], v; i; i = nx[i])
    if (pre[v = to[i]])
      inst[v] ? low[u] = min(low[u], pre[v]) : 0;
    else
      dfs(v), low[u] = min(low[u], low[v]);
  if (pre[u] == low[u]) {
    ++scc_cnt;
    while (1) {
      inst[st[top]] = 0, scc_id[st[top]] = scc_cnt;
      if (st[top--] == u) break;
    }
  }
}
int thd[400005], tcnt;
bool check(int x) {
  for (int i = 1; i <= idcnt; ++i) hd[i] = thd[i], pre[i] = 0;
  cnt = tcnt, dfn = 0, scc_cnt = 0;
  for (int i = 1; i <= m; ++i)
    if (e[i].w > x) add(i << 1, (i << 1) - 1);
  for (int i = 1; i <= idcnt; ++i)
    if (!pre[i]) dfs(i);
  for (int i = 1; i <= m; ++i)
    if (scc_id[i << 1] == scc_id[(i << 1) - 1]) return 0;
  return 1;
}
int res;
int main() {
  n = read(), m = read(), idcnt = m << 1;
  for (int i = 1; i <= m; ++i) e[i].id = i, e[i].init();
  for (int u = 1, s, t, c; u <= n; ++u) {
    if (!p[u].size()) continue;
    sort(p[u].begin(), p[u].end(), cmp), c = 0;
    for (int i = 0; i < p[u].size(); ++i)
      if (i + 1 < p[u].size() && e[p[u][i]].c == e[p[u][i + 1]].c) {
        if (c) return puts("No"), 0;
        add((p[u][i] << 1) - 1, p[u][i + 1] << 1);
        add((p[u][i + 1] << 1) - 1, p[u][i] << 1);
      }
    s = (p[u].front() << 1) - 1, t = p[u].front() << 1;
    for (int i = 1; i < p[u].size(); ++i) {
      add(p[u][i] << 1, s), add(t, (p[u][i] << 1) - 1);
      add(++idcnt, s), add(s = idcnt, (p[u][i] << 1) - 1);
      add(t, ++idcnt), add(p[u][i] << 1, t = idcnt);
    }
  }
  int l = 0, r = 1000000000, rs = r, mid;
  for (int i = 1; i <= idcnt; ++i) thd[i] = hd[i];
  tcnt = cnt;
  if (!check(r)) return puts("No"), 0;
  while (l <= r)
    check(mid = l + r >> 1) ? (rs = mid, r = mid - 1) : l = mid + 1;
  check(rs);
  puts("Yes");
  for (int i = 1; i <= m; ++i)
    if (scc_id[i << 1] < scc_id[(i << 1) - 1]) st[++res] = i;
  printf("%d %d\n", rs, res);
  for (int i = 1; i <= res; ++i) printf("%d ", st[i]);
  return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
int read() {
  int x = 0, f = 1;
  char c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
            (iS == iT ? EOF : *iS++) : *iS++);
  while (!isdigit(c))
    f = (c == '-') ? -1 : f,
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  while (isdigit(c))
    x = x * 10 + c - '0',
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  return x * f;
}
