#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m, cnt, tot, t[N], o[N], dfn[N], low[N], tim, S[N], vis[N], bel[N], scc;
vector<int> vec[N], E[N];
map<pair<int, int>, int> Map;
int ID(int x, int y) {
  if (!Map.count({x, y})) Map[{x, y}] = ++cnt;
  return Map[{x, y}];
}
void link(int x, int y) {
  E[x].push_back(y);
  E[y ^ 1].push_back(x ^ 1);
}
void Tarjan(int x) {
  dfn[x] = low[x] = ++tim;
  vis[S[++S[0]] = x] = 1;
  for (int y : E[x])
    if (!dfn[y])
      Tarjan(y), low[x] = min(low[x], low[y]);
    else if (vis[y])
      low[x] = min(low[x], dfn[y]);
  if (dfn[x] == low[x]) {
    ++scc;
    int y;
    do y = S[S[0]--], bel[y] = scc, vis[y] = 0;
    while (x != y);
  }
}
bool check(int mid) {
  for (int i = 2; i <= (tot << 1 | 1); ++i) dfn[i] = 0;
  tim = scc = 0;
  for (int i = 1; i <= m; ++i)
    if (t[i] > mid) E[i << 1].push_back(i << 1 | 1);
  for (int i = 2; i <= (tot << 1 | 1); ++i)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= m; ++i)
    if (t[i] > mid) E[i << 1].pop_back();
  for (int i = 1; i <= tot; ++i)
    if (bel[i << 1] == bel[i << 1 | 1]) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  cnt = n;
  tot = m;
  for (int i = 1, u, v, c; i <= m; ++i) {
    scanf("%d%d%d%d", &u, &v, &c, &t[i]);
    o[i] = t[i];
    vec[u].push_back(i << 1);
    vec[v].push_back(i << 1);
    vec[ID(u, c)].push_back(i << 1 | 1);
    vec[ID(v, c)].push_back(i << 1 | 1);
  }
  for (int i = 1; i <= cnt; ++i)
    if (vec[i].size() >= 2) {
      for (int j = 0; j < vec[i].size(); ++j) {
        link(vec[i][j], tot + j + 1 << 1);
        if (j) {
          link(tot + j << 1, vec[i][j] ^ 1);
          link(tot + j << 1, tot + j + 1 << 1);
        }
      }
      tot += vec[i].size();
    }
  sort(o + 1, o + m + 1);
  int l = 0, r = m, res = m + 1;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(o[mid]))
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  if (res == m + 1)
    puts("No");
  else {
    puts("Yes");
    check(o[res]);
    int ans = 0;
    for (int i = 1; i <= m; ++i) ans += bel[i << 1] < bel[i << 1 | 1];
    printf("%d %d\n", o[res], ans);
    for (int i = 1; i <= m; ++i)
      if (bel[i << 1] < bel[i << 1 | 1]) printf("%d ", i);
    puts("");
  }
  return 0;
}
