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 c;
  int t;
  int idx;
  edge() {}
  edge(int c, int t, int idx) : c(c), t(t), idx(idx) {}
};
map<int, int> mapa[500005];
vector<int> g[500005];
vector<edge> w[500005];
int del[500005];
int color[500005];
int used[500005];
int ok;
vector<int> list;
void DFS(int node) {
  set<int> got;
  used[node] = 1;
  int count = 0;
  for (int i = 0; i < (int)g[node].size(); i++) {
    int viz = g[node][i];
    if (got.find(viz) == got.end()) {
      got.insert(viz);
      count += del[node] && del[viz];
    }
    if (!used[viz]) {
      DFS(viz);
    }
  }
  if (count > 1) {
    ok = 0;
  }
  return;
}
int main(void) {
  int n, m;
  int v, u, c, t;
  scanf(" %d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    del[i] = 0;
    used[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    scanf(" %d %d %d %d", &v, &u, &c, &t);
    mapa[v][c]++;
    mapa[u][c]++;
    g[v].push_back(u);
    g[u].push_back(v);
    w[v].push_back(edge(c, t, i + 1));
    w[u].push_back(edge(c, t, i + 1));
  }
  for (int i = 1; i <= n; i++) {
    for (map<int, int>::iterator it = mapa[i].begin(); it != mapa[i].end();
         it++) {
      if ((*it).second >= 2) {
        del[i] = 1;
        color[i] = (*it).first;
        break;
      }
    }
  }
  ok = 1;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      DFS(i);
    }
  }
  if (!ok) {
    printf("No\n");
  } else {
    int r = 0;
    for (int i = 1; i <= n; i++) {
      if (del[i] == 1) {
        int idx = 0;
        int mini = 0x3f3f3f3f;
        for (int j = 0; j < (int)g[i].size(); j++) {
          int viz = g[i][j];
          if (del[viz] == 1) {
            if (w[i][j].c == color[i]) {
              if (w[i][j].t < mini) {
                mini = w[i][j].t;
                idx = j;
              }
            }
          }
        }
        if (mini == 0x3f3f3f3f) {
          for (int j = 0; j < (int)g[i].size(); j++) {
            if (w[i][j].c == color[i]) {
              if (w[i][j].t < mini) {
                mini = w[i][j].t;
                idx = j;
              }
            }
          }
        }
        list.push_back(w[i][idx].idx);
        r = max(r, mini);
        int viz = g[i][idx];
        del[i] = del[viz] = 0;
        mapa[i][color[i]]--;
        mapa[viz][color[i]]--;
      }
    }
    for (int i = 1; i <= n; i++) {
      for (map<int, int>::iterator it = mapa[i].begin(); it != mapa[i].end();
           it++) {
        if ((*it).second >= 2) {
          ok = 0;
          i = n + 1;
          break;
        }
      }
    }
    if (ok) {
      printf("Yes\n");
      printf("%d %d\n", r, (int)list.size());
      for (int i = 0; i < (int)list.size(); i++) {
        if (i != 0) {
          printf(" ");
        }
        printf("%d", list[i]);
      }
      printf("\n");
    }
  }
  return 0;
}
