#include <bits/stdc++.h>
using namespace std;
const int N = 50005, M = 50005, inf = 1000000005;
template <class T>
void read(T &x) {
  int sgn = 1;
  char ch;
  x = 0;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') ch = getchar(), sgn = -1;
  for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= sgn;
}
template <class T>
void write(T x) {
  if (x < 0)
    putchar('-'), write(-x);
  else if (x < 10)
    putchar(x + '0');
  else
    write(x / 10), putchar(x % 10 + '0');
}
struct edge {
  int to, nxt, col, t;
} graph[M * 12 + N * 4];
int n, m, t_lim, head[N], cnt = 0;
void addedge(int u, int v, int col, int t) {
  edge e = {v, head[u], col, t};
  graph[head[u] = cnt++] = e;
}
int dfn[M * 12 + N * 4], low[M * 12 + N * 4], scc[M * 12 + N * 4],
    tot = 0, now = 0, t = 0;
vector<int> g[M * 12 + N * 4];
stack<int> stk;
bool vis[M * 12 + N * 4], flag = true;
void dfs(int u) {
  dfn[u] = low[u] = ++now;
  stk.push(u), vis[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!dfn[v])
      dfs(v), low[u] = min(low[u], low[v]);
    else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (u < (m << 1) && graph[u].t > t_lim && (u & 1)) {
    int v = u ^ 1;
    if (!dfn[v])
      dfs(v), low[u] = min(low[u], low[v]);
    else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    t++;
    for (;;) {
      int v = stk.top();
      vis[v] = false;
      stk.pop(), scc[v] = t;
      if (v == u) break;
    }
  }
}
bool check() {
  for (int i = 0; i < tot; i++) dfn[i << 1] = dfn[i << 1 | 1] = 0;
  for (int i = 0; i < tot; i++) {
    if (!dfn[i << 1]) dfs(i << 1);
    if (!dfn[i << 1 | 1]) dfs(i << 1 | 1);
  }
  for (int i = 0; i < tot; i++) {
    if (scc[i << 1] == scc[i << 1 | 1]) return false;
  }
  return flag;
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 0; i < m; i++) {
    int u, v, c, t;
    read(u), read(v), read(c), read(t);
    addedge(u, v, c, t), addedge(v, u, c, t);
  }
  tot = m;
  for (int i = 1; i <= n; i++) {
    int total = 0, e1, e2;
    vector<int> adj;
    map<int, int> id;
    for (int j = head[i]; ~j; j = graph[j].nxt) {
      if (id[graph[j].col]) {
        e1 = id[graph[j].col], e2 = j;
        total++;
      }
      id[graph[j].col] = j, adj.push_back(j);
    }
    if (total > 1)
      flag = false;
    else if (total) {
      for (int j = head[i]; ~j; j = graph[j].nxt) {
        if (j != e1 && j != e2) g[j ^ (j & 1) ^ 1].push_back(j ^ (j & 1));
      }
      g[e1 ^ (e1 & 1)].push_back(e2 ^ (e2 & 1) ^ 1);
      g[e2 ^ (e2 & 1)].push_back(e1 ^ (e1 & 1) ^ 1);
      g[e1 ^ (e1 & 1) ^ 1].push_back(e2 ^ (e2 & 1));
      g[e2 ^ (e2 & 1) ^ 1].push_back(e1 ^ (e1 & 1));
    } else {
      int s = adj.size();
      vector<int> pre, suf;
      pre.push_back(tot++);
      for (int j = 0; j < s; j++) {
        pre.push_back(tot);
        g[adj[j] ^ (adj[j] & 1) ^ 1].push_back(tot << 1 | 1);
        g[tot << 1].push_back(adj[j] ^ (adj[j] & 1));
        g[pre[j] << 1 | 1].push_back(tot << 1 | 1);
        g[tot << 1].push_back(pre[j] << 1);
        tot++;
      }
      suf.push_back(tot++);
      for (int j = s - 1; j >= 0; j--) {
        suf.push_back(tot);
        g[adj[j] ^ (adj[j] & 1) ^ 1].push_back(tot << 1 | 1);
        g[tot << 1].push_back(adj[j] ^ (adj[j] & 1));
        g[suf[s - j] << 1 | 1].push_back(tot << 1 | 1);
        g[tot << 1].push_back(suf[s - j] << 1);
        tot++;
      }
      for (int j = 0; j < s; j++) {
        g[adj[j] ^ (adj[j] & 1) ^ 1].push_back(pre[j] << 1);
        g[pre[j] << 1 | 1].push_back(adj[j] ^ (adj[j] & 1));
        g[adj[j] ^ (adj[j] & 1) ^ 1].push_back(suf[s - 1 - j] << 1);
        g[suf[s - 1 - j] << 1 | 1].push_back(adj[j] ^ (adj[j] & 1));
      }
    }
  }
  int l = 0, r = inf;
  while (l < r) {
    int mid = l + r >> 1;
    t_lim = mid, now = t = 0;
    if (check())
      r = mid;
    else
      l = mid + 1;
  }
  if (l >= inf)
    puts("No");
  else {
    int total = 0;
    t_lim = l, check();
    for (int i = 0; i < m; i++) {
      if (scc[i << 1 | 1] < scc[i << 1]) total++;
    }
    puts("Yes");
    write(l), putchar(' ');
    write(total), putchar('\n');
    for (int i = 0; i < m; i++) {
      if (scc[i << 1 | 1] < scc[i << 1]) write(i + 1), putchar(' ');
    }
    putchar('\n');
  }
  return 0;
}
