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;
const int N = 1e6 + 10;
int ans, L, R, tot = 1, col, top, lys, zdy, cnt, n, m, vis[N], c[N], st[N],
               mark[N], dfn[N], f[N], low[N], bl[N], lsh[N], head[N], d[N],
               to[N], ne[N], w[N], s[2][N];
vector<int> e[N];
void link(int x, int y, int l, int r) {
  d[x]++;
  to[++tot] = y;
  ne[tot] = head[x];
  c[tot] = l, w[tot] = r;
  head[x] = tot;
}
void add(int x, int y) { e[x].push_back(y); }
void Tarjan(int x) {
  st[++top] = x;
  mark[x] = 1;
  dfn[x] = low[x] = ++zdy;
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (!dfn[y]) {
      Tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (mark[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    col++;
    while (1) {
      int y = st[top--];
      bl[y] = col;
      mark[y] = 0;
      if (y == x) break;
    }
  }
}
bool check(int x) {
  int val = 1;
  zdy = col = top = 0;
  cnt = m * 2;
  for (int i = 1; i <= n && val; i++) {
    for (int j = 1; j <= d[i]; j++) s[0][j] = ++cnt, s[1][j] = ++cnt;
    for (int j = head[i], k = 1; j; j = ne[j], k++) {
      f[c[j]]++;
      if (f[c[j]] > 2) val = 0;
      if (f[c[j]] == 2)
        add(vis[c[j]] * 2 - 1, (j >> 1) * 2),
            add((j >> 1) * 2 - 1, vis[c[j]] * 2);
      vis[c[j]] = j >> 1;
      if (k != d[i]) {
        add((j >> 1) * 2, s[0][k + 1]), add(s[1][k + 1], (j >> 1) * 2 - 1);
        add(s[0][k], s[0][k + 1]), add(s[1][k + 1], s[1][k]);
      }
      add(s[0][k], (j >> 1) * 2 - 1), add((j >> 1) * 2, s[1][k]);
    }
    for (int j = head[i]; j; j = ne[j]) f[c[j]] = 0;
  }
  for (int i = 1; i <= m; i++)
    if (w[i << 1] > x) add(i * 2, i * 2 - 1);
  for (int i = 1; i <= cnt; i++)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= m; i++)
    if (bl[i * 2] == bl[i * 2 - 1]) val = 0;
  for (int i = 1; i <= cnt; i++) e[i].clear(), dfn[i] = low[i] = mark[i] = 0;
  return val;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y, l, r; i <= m; i++) {
    scanf("%d%d%d%d", &x, &y, &l, &r);
    link(x, y, l, r), link(y, x, l, r);
    lsh[++lys] = l;
    R = max(R, r);
  }
  sort(lsh + 1, lsh + lys + 1);
  lys = unique(lsh + 1, lsh + lys + 1) - lsh - 1;
  for (int i = 1; i <= tot; i++)
    c[i] = lower_bound(lsh + 1, lsh + lys + 1, c[i]) - lsh;
  while (L < R) {
    int mid = (L + R) >> 1;
    if (check(mid))
      ans = 1, R = mid;
    else
      L = mid + 1;
  }
  if (!ans)
    puts("No");
  else {
    check(L);
    puts("Yes");
    vector<int> v;
    for (int i = 1; i <= m; i++) {
      if (bl[i * 2 - 1] > bl[i * 2]) {
        v.push_back(i);
      }
    }
    printf("%d %d\n", L, v.size());
    for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  }
  return 0;
}
