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;
struct edge {
  int u, v, c, w;
} e[100011 * 4];
int n, m, mx = 0, now;
vector<int> p[100011], lk[100011 * 4], tmp;
bool cmp(int a, int b) { return e[a].c < e[b].c; }
int dfn[100011], inl[100011], g[100011], D, cnt, low[100011];
stack<int> V;
void tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  inl[x] = 1;
  V.push(x);
  for (auto y : lk[x]) {
    if (!dfn[y])
      tarjan(y), low[x] = min(low[x], low[y]);
    else {
      if (inl[y]) low[x] = min(low[x], dfn[y]);
    }
  }
  if (dfn[x] == low[x]) {
    ++D;
    int y;
    do {
      y = V.top();
      V.pop();
      g[y] = D;
      inl[y] = 0;
    } while (y != x);
  }
}
bool check(int x) {
  for (int i = 1; i <= m; i++)
    if (e[i].w > x) {
      lk[i].push_back(i + m);
    }
  cnt = 0;
  D = 0;
  memset(dfn, 0, sizeof(dfn));
  for (int i = 1; i <= now; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (e[i].w > x) lk[i].pop_back();
  for (int i = 1; i <= m; i++) {
    if (g[i] == g[i + m]) return 0;
  }
  return 1;
}
void add(int tp) {
  int emp = now + 2;
  for (auto x : tmp) {
    int y = x + m;
    now += 2;
    if (!tp) {
      lk[x].push_back(now);
      lk[now - 1].push_back(y);
      if (now > emp) {
        lk[now - 2].push_back(now), lk[now - 1].push_back(now - 3);
        lk[x].push_back(now - 3), lk[now - 2].push_back(y);
      }
    } else {
      lk[now].push_back(x);
      lk[y].push_back(now - 1);
      if (now > emp) {
        lk[now].push_back(now - 2), lk[now - 3].push_back(now - 1);
        lk[now - 3].push_back(x), lk[y].push_back(now - 2);
      }
    }
  }
  tmp.clear();
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, a, b, c, t; i <= m; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &t);
    mx = max(mx, t);
    e[i] = (edge){a, b, c, t};
    p[a].push_back(i);
    p[b].push_back(i);
  }
  e[m + 1] = (edge){0, 0, 1000000009, 1000000009};
  for (int i = 1; i <= n; i++) sort(p[i].begin(), p[i].end(), cmp);
  now = 2 * m;
  for (int i = 1; i <= n; i++) {
    tmp = p[i];
    add(0);
    p[i].push_back(m + 1);
    for (int j = 0; j < (int)p[i].size() - 1; j++) {
      tmp.push_back(p[i][j]);
      if (e[p[i][j]].c != e[p[i][j + 1]].c) add(1);
    }
  }
  int l = 0, r = mx;
  if (!check(r)) {
    puts("No");
    return 0;
  }
  puts("Yes");
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  r = 0;
  for (int i = 1; i <= m; i++)
    if (g[i] < g[i + m]) lk[0].push_back(i), r = max(r, e[i].w);
  printf("%d %d\n", r, (int)lk[0].size());
  for (auto i : lk[0]) printf("%d ", i);
}
