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, w[1234567], c[1234567], fir[1234567], l[1234567], to[1234567], ec, pc,
    bl[1234567], dfn[1234567], low[1234567], tim, sta[1234567], ins[1234567],
    top, scc;
vector<int> E[1234567];
void link(int a, int b) {
  l[++ec] = fir[a];
  fir[a] = ec;
  to[ec] = b;
}
bool cmp(int a, int b) { return c[a] < c[b]; }
void dfs(int p) {
  dfn[p] = low[p] = ++tim;
  ins[sta[++top] = p] = 1;
  for (int i = fir[p], y; y = to[i]; i = l[i])
    if (!dfn[y])
      dfs(y), low[p] = min(low[p], low[y]);
    else if (ins[y])
      low[p] = min(low[p], dfn[y]);
  if (low[p] == dfn[p]) {
    scc++;
    while (ins[p]) bl[sta[top]] = scc, ins[sta[top--]] = 0;
  }
}
bool chk(int x) {
  pc = m << 1 | 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j < E[i].size(); ++j)
      if (c[E[i][j]] == c[E[i][j - 1]])
        link(E[i][j] << 1 | 1, E[i][j - 1] << 1),
            link(E[i][j - 1] << 1 | 1, E[i][j] << 1);
  for (int i = 1; i <= m; ++i)
    if (w[i] > x) link(i << 1, i << 1 | 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < (int)E[i].size() - 1; ++j) {
      ++pc, link(pc, E[i][j] << 1 | 1), link(E[i][j + 1] << 1, pc);
      if (j) link(pc, pc - 1);
    }
  for (int i = 1; i <= n; ++i)
    for (int j = (int)E[i].size() - 1; j >= 1; --j) {
      ++pc, link(pc, E[i][j] << 1 | 1), link(E[i][j - 1] << 1, pc);
      if (j != E[i].size() - 1) link(pc, pc - 1);
    }
  for (int i = 2; i <= pc; ++i)
    if (!dfn[i]) dfs(i);
  for (int i = 2; i <= pc; ++i) fir[i] = dfn[i] = 0;
  ec = 0;
  for (int i = 1; i <= m; ++i)
    if (bl[i << 1] == bl[i << 1 | 1]) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i)
    scanf("%d%d%d%d", &x, &y, &c[i], &w[i]), E[x].push_back(i),
        E[y].push_back(i);
  for (int i = 1; i <= n; ++i) sort(E[i].begin(), E[i].end(), cmp);
  for (int i = 1; i <= n; ++i)
    for (int j = 2; j < E[i].size(); ++j)
      if (c[E[i][j]] == c[E[i][j - 2]]) return puts("No"), 0;
  int l = 0, r = 1000000000, a = 2e9, md, cnt = 0;
  while (md = l + r >> 1, l <= r)
    if (chk(md))
      r = md - 1, a = md;
    else
      l = md + 1;
  if (a > 1e9) return puts("No"), 0;
  chk(a);
  for (int i = 1; i <= m; ++i)
    if (bl[i << 1] < bl[i << 1 | 1]) cnt++;
  printf("Yes\n%d %d\n", a, cnt);
  for (int i = 1; i <= m; ++i)
    if (bl[i << 1] < bl[i << 1 | 1]) printf("%d ", i);
}
