#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
int addnum, vel[800010], ne[800010], head[800010];
int dfn[300010], low[300010], vis[300010], q[300010], co[300010];
int tim, col, top;
int n, m, cnt;
int pre[50010], nex[50010];
int tot, s[50010];
vector<int> o[50010];
int x[50010], y[50010], c[50010], t[50010];
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  return ans;
}
void add(int u, int v) {
  addnum++, vel[addnum] = v, ne[addnum] = head[u], head[u] = addnum;
}
void tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  vis[u] = 1;
  q[++top] = u;
  for (int e = head[u]; e; e = ne[e]) {
    int v = vel[e];
    if (!vis[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (vis[v] == 1)
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u]) {
    col++;
    while (q[top] != u) vis[q[top]] = 2, co[q[top--]] = col;
    vis[q[top]] = 2, co[q[top--]] = col;
  }
}
int check(int num) {
  addnum = 0;
  col = 0;
  tim = 0;
  top = 0;
  for (int i = 1; i <= m * 6; i++) head[i] = vis[i] = co[i] = 0;
  cnt = m + m;
  for (int i = 1; i <= n; i++) {
    int siz = o[i].size();
    for (int j = 0; j < siz; j++) pre[j] = ++cnt;
    for (int j = siz - 1; j >= 0; j--) nex[j] = ++cnt;
    for (int j = 0; j < siz; j++) {
      int u = o[i][j];
      if (t[u] > num) add(u, u + m);
      if (j) add(u, pre[j - 1]), add(pre[j], pre[j - 1]);
      if (j + 1 < siz) add(u, nex[j + 1]), add(nex[j], nex[j + 1]);
      add(pre[j], u + m), add(nex[j], u + m);
    }
    for (int j = 1; j < siz; j++) {
      if (c[o[i][j]] == c[o[i][j - 1]]) {
        if (j + 1 < siz && c[o[i][j]] == c[o[i][j + 1]]) return 0;
        add(o[i][j] + m, o[i][j - 1]);
        add(o[i][j - 1] + m, o[i][j]);
      }
    }
  }
  for (int i = 1; i <= cnt; i++)
    if (!vis[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (co[i] == co[i + m]) return 0;
  return 1;
}
inline int cmp(int x, int y) { return c[x] < c[y]; }
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    x[i] = read(), y[i] = read(), c[i] = read(), t[i] = read();
    o[x[i]].push_back(i);
    o[y[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) sort(o[i].begin(), o[i].end(), cmp);
  int l = 0, r = inf;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (r == inf) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  check(r);
  for (int i = 1; i <= m; i++)
    if (co[i] < co[i + m]) s[++tot] = i;
  printf("%d %d\n", r, tot);
  for (int i = 1; i <= tot; i++) printf("%d%c", s[i], i == tot ? '\n' : ' ');
}
