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;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int fh = 1;
  while (!isdigit(c)) {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= fh;
}
int m, n, df[1000010], lo[1000010], st[1000010], nst, bi[1000010], nu, num, ns;
bool v1[1000010], v2[1000010];
vector<int> s[50010], t[50010], a[1000010];
struct edg {
  int x, y, c, t, we;
} e[50010];
bool c1(const edg &a, const edg &b) { return a.c < b.c; }
void jb(int x, int y) {
  a[x].push_back(y);
  a[y ^ 1].push_back(x ^ 1);
}
void tarjan(int x) {
  st[++nst] = x;
  lo[x] = df[x] = ++num;
  v1[x] = v2[x] = 0;
  for (unsigned i = 0; i < a[x].size(); i++) {
    if (v1[a[x][i]]) {
      tarjan(a[x][i]);
      lo[x] = min(lo[x], lo[a[x][i]]);
    } else if (!v2[a[x][i]])
      lo[x] = min(lo[x], df[a[x][i]]);
  }
  if (lo[x] == df[x]) {
    nu++;
    while (st[nst] != x) {
      bi[st[nst]] = nu;
      v2[st[nst]] = 1;
      nst--;
    }
    bi[st[nst]] = nu;
    v2[st[nst]] = 1;
    nst--;
  }
}
bool pa(int x) {
  for (int i = 1; i <= m; i++)
    if (e[i].t > x) a[i * 2 + 1].push_back(i * 2);
  for (int i = 2; i < ns; i++) v1[i] = v2[i] = 1;
  num = nu = 0;
  for (int i = 2; i < ns; i++)
    if (v1[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (e[i].t > x) a[i * 2 + 1].pop_back();
  for (int i = 2; i < ns; i += 2)
    if (bi[i + 1] == bi[i]) return 0;
  return 1;
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= m; i++) {
    read(e[i].x);
    read(e[i].y);
    read(e[i].c);
    read(e[i].t);
    e[i].we = i;
  }
  sort(e + 1, e + m + 1, c1);
  for (int l = 1, r = 0; l <= m; l = r + 1) {
    while (e[r + 1].c == e[l].c && r + 1 <= m) r++;
    for (int i = l; i <= r; i++) {
      s[e[i].x].push_back(i);
      s[e[i].y].push_back(i);
      t[e[i].x].push_back(i * 2);
      t[e[i].y].push_back(i * 2);
      if (t[e[i].x].size() >= 3) {
        puts("No");
        return 0;
      }
      if (t[e[i].y].size() >= 3) {
        puts("No");
        return 0;
      }
      if (t[e[i].x].size() == 2) jb(t[e[i].x][0], t[e[i].x][1] + 1);
      if (t[e[i].y].size() == 2) jb(t[e[i].y][0], t[e[i].y][1] + 1);
    }
    for (int i = l; i <= r; i++) {
      t[e[i].x].pop_back();
      t[e[i].y].pop_back();
    }
  }
  ns = 2 * m + 2;
  for (int i = 1; i <= n; i++) {
    for (unsigned j = 0; j < s[i].size(); j++) {
      if (j != 0) {
        jb(ns, ns - 4);
        jb(s[i][j] * 2 + 1, ns - 4);
      }
      if (j != s[i].size() - 1) {
        jb(ns + 2, ns + 6);
        jb(s[i][j] * 2 + 1, ns + 6);
      }
      jb(ns, s[i][j] * 2);
      jb(ns + 2, s[i][j] * 2);
      ns += 4;
    }
  }
  if (pa(1e9)) {
    int l = 0, r = 1e9, mid;
    while (l < r) {
      mid = (l + r) / 2;
      if (pa(mid))
        r = mid;
      else
        l = mid + 1;
    }
    pa(l);
    puts("Yes");
    vector<int> an;
    an.clear();
    cout << l << ' ';
    for (int i = 1; i <= m; i++)
      if (bi[i * 2 + 1] < bi[i * 2]) an.push_back(e[i].we);
    cout << an.size() << endl;
    for (unsigned i = 0; i < an.size(); i++) cout << an[i] << ' ';
    cout << endl;
  } else {
    puts("No");
  }
  return 0;
}
