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 v, nxt;
} e[2000010];
int tot;
int first[200010];
void build(int u, int v) {
  e[++tot] = (Edge){v, first[u]};
  first[u] = tot;
  return;
}
int dfn[1000010], low[1000010], now;
int c[1000010], color;
int sta[1000010], head;
bool insta[1000010];
void dfs(int u) {
  dfn[u] = low[u] = ++now;
  sta[++head] = u;
  insta[u] = true;
  for (int i = first[u]; i; i = e[i].nxt)
    if (!dfn[e[i].v]) {
      dfs(e[i].v);
      low[u] = min(low[u], low[e[i].v]);
    } else if (insta[e[i].v])
      low[u] = min(low[u], dfn[e[i].v]);
  if (dfn[u] == low[u]) {
    color++;
    do {
      c[sta[head]] = color;
      insta[sta[head]] = false;
    } while (sta[head--] != u);
  }
  return;
}
int n, m;
int ans[50010];
int col[50010], tim[50010];
vector<int> vec[50010];
void work(int u) {
  bool flag = false;
  map<int, int> pre;
  for (int i = 0; i < vec[u].size(); i++) {
    int id = vec[u][i];
    build(id, id + m * 2);
    build(id + m * 3, id + m);
    if (i > 0) {
      build(id, vec[u][i - 1] + m * 3);
      build(vec[u][i - 1] + m * 2, id + m);
      build(id + m * 3, vec[u][i - 1] + m * 3);
      build(vec[u][i - 1] + m * 2, id + m * 2);
    }
    if (!pre.count(col[id]))
      pre[col[id]] = id;
    else {
      int ind = pre[col[id]];
      if (flag) {
        printf("No\n");
        exit(0);
      }
      flag = true;
      build(ind + m, id);
      build(id + m, ind);
      pre[col[id]] = id;
    }
  }
  return;
}
bool check(int T) {
  color = 0;
  now = 0;
  tot = 0;
  memset(first, 0, sizeof(first));
  for (int i = 1; i <= n; i++) work(i);
  for (int i = 1; i <= m; i++)
    if (tim[i] > T) build(i, i + m);
  memset(dfn, 0, sizeof(dfn));
  for (int i = 1; i <= 4 * m; i++)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= m; i++)
    if (c[i] == c[i + m])
      return false;
    else if (c[i] < c[i + m])
      ans[i] = 1;
    else
      ans[i] = 0;
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d %d %d", &u, &v, &col[i], &tim[i]);
    vec[u].push_back(i);
    vec[v].push_back(i);
  }
  int l = -1, r = 1000000001;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (!check(r))
    printf("No\n");
  else {
    printf("Yes\n");
    int k = 0;
    for (int i = 1; i <= m; i++) k += ans[i];
    printf("%d %d\n", r, k);
    for (int i = 1; i <= m; i++)
      if (ans[i]) printf("%d ", i);
  }
  return 0;
}
