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, tot, q[500005];
int fir[500005], tar[2000005], nex[2000005], cnt;
int dfn[500005], low[500005], deg[500005], tim;
int scc[500005], col[500005], stk[500005], top, lev;
vector<int> all[500005];
vector<int> neb[500005];
struct Node {
  int u, v, c, d;
} S[500005];
void Add(int a, int b) {
  cnt++;
  tar[cnt] = b;
  nex[cnt] = fir[a];
  fir[a] = cnt;
}
bool cmp(int a, int b) { return S[a].c < S[b].c; }
void Work1() {
  for (int i = 1; i <= q[0]; i++) {
    Add(((q[i]) * 2 - 1), ((i)*2 - 1) + tot);
    Add(((i)*2) + tot, ((q[i]) * 2));
    if (i != 1) {
      Add(((i - 1) * 2 - 1) + tot, ((i)*2 - 1) + tot);
      Add(((i)*2) + tot, ((i - 1) * 2) + tot);
      Add(((i - 1) * 2 - 1) + tot, ((q[i]) * 2));
      Add(((q[i]) * 2 - 1), ((i - 1) * 2) + tot);
    }
  }
  tot += q[0] * 2;
  q[0] = 0;
}
void Work2() {
  for (int i = 1; i <= q[0]; i++) {
    Add(((q[i]) * 2), ((i)*2) + tot);
    Add(((i)*2 - 1) + tot, ((q[i]) * 2 - 1));
    if (i != 1) {
      Add(((i - 1) * 2) + tot, ((i)*2) + tot);
      Add(((i)*2 - 1) + tot, ((i - 1) * 2 - 1) + tot);
      Add(((i - 1) * 2) + tot, ((q[i]) * 2 - 1));
      Add(((q[i]) * 2), ((i - 1) * 2 - 1) + tot);
    }
  }
  tot += q[0] * 2;
  q[0] = 0;
}
void Dfs(int r) {
  dfn[r] = low[r] = ++tim;
  stk[++top] = r;
  for (int i = fir[r]; i; i = nex[i]) {
    int v = tar[i];
    if (!dfn[v]) {
      Dfs(v);
      low[r] = min(low[r], low[v]);
    } else if (!scc[v])
      low[r] = min(low[r], dfn[v]);
  }
  if (dfn[r] == low[r]) {
    ++lev;
    do {
      scc[stk[top]] = lev;
      all[lev].push_back(stk[top]);
    } while (stk[top--] != r);
  }
}
bool Check(int mid) {
  tot = m * 2;
  cnt = 0;
  memset(fir, 0, sizeof(fir));
  for (int i = 1; i <= m; i++)
    if (S[i].d > mid) Add(((i)*2), ((i)*2 - 1));
  for (int i = 1; i <= n; i++) {
    int t = neb[i].size();
    for (int j = 0; j < t; j++) {
      int x = neb[i][j];
      if (q[0] && S[x].c != S[q[q[0]]].c) Work1();
      q[++q[0]] = x;
    }
    Work1();
    for (int j = 0; j < t; j++) {
      int x = neb[i][j];
      q[++q[0]] = x;
    }
    Work2();
  }
  memset(dfn, 0, sizeof(dfn));
  memset(scc, 0, sizeof(scc));
  lev = tim = 0;
  for (int i = 1; i <= tot; i++)
    if (!dfn[i]) Dfs(i);
  for (int i = 1; i <= tot; i += 2)
    if (scc[i] == scc[i + 1]) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  int l = 0, r = 0, flg = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d", &S[i].u, &S[i].v, &S[i].c, &S[i].d);
    r = max(r, S[i].d + 1);
    neb[S[i].u].push_back(i);
    neb[S[i].v].push_back(i);
  }
  for (int i = 1; i <= n; i++) sort(neb[i].begin(), neb[i].end(), cmp);
  while (l < r) {
    int mid = (l + r) >> 1;
    if (Check(mid))
      r = mid, flg = 1;
    else
      l = mid + 1;
  }
  if (!flg) {
    puts("No");
    return 0;
  }
  Check(l);
  tot = 0;
  for (int i = 1; i <= m; i++)
    if (scc[((i)*2 - 1)] > scc[((i)*2)]) q[++tot] = i;
  printf("Yes\n%d %d\n", l, tot);
  for (int i = 1; i <= tot; i++) printf("%d%c", q[i], i == tot ? 10 : 32);
}
