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;
int n, m, N;
struct node {
  int x, y, c, t;
} e[50005];
vector<int> G[50005], E[500005], ans;
bool cmp(int i, int j) { return e[i].c < e[j].c; }
void add(int x, int y) { E[x].push_back(y), E[y ^ 1].push_back(x ^ 1); }
void Line1(vector<int> &A) {
  for (int i = 0, sz = A.size(); i < sz; i++) {
    add(N += 2, (((A[i]) * 2) ^ (1)));
    if (i) add(N, N - 2), add((((A[i]) * 2) ^ (0)), N - 2);
  }
}
int dfn[500005], low[500005], stk[500005], top, tim, scc[500005], scnt;
void tarjan(int u) {
  dfn[u] = low[u] = ++tim, stk[++top] = u;
  for (int v : E[u])
    if (!dfn[v])
      tarjan(v), low[u] = min(low[u], low[v]);
    else if (!scc[v])
      low[u] = min(low[u], dfn[v]);
  if (dfn[u] == low[u]) {
    ++scnt;
    do scc[stk[top]] = scnt;
    while (stk[top--] != u);
  }
}
void del(int mid) {
  for (int i = 1; i <= m; i++)
    if (e[i].t > mid) E[(((i)*2) ^ (0))].pop_back();
}
bool check(int mid) {
  for (int i = 1; i <= m; i++)
    if (e[i].t > mid) E[(((i)*2) ^ (0))].push_back((((i)*2) ^ (1)));
  for (int i = 2; i <= N + 1; i++) dfn[i] = scc[i] = 0;
  tim = scnt = 0;
  for (int i = 2; i <= N + 1; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (scc[(((i)*2) ^ (0))] == scc[(((i)*2) ^ (1))]) return del(mid), 0;
  return del(mid), 1;
}
int main() {
  int l = 0, r = 0, mid;
  scanf("%d%d", &n, &m), N = 2 * m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d", &e[i].x, &e[i].y, &e[i].c, &e[i].t), r = max(r, e[i].t);
    G[e[i].x].push_back(i), G[e[i].y].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    sort(G[i].begin(), G[i].end(), cmp);
    Line1(G[i]);
    for (int j = 0, k, sz = G[i].size(); j < sz; j = k) {
      for (k = j; k < sz && e[G[i][j]].c == e[G[i][k]].c; k++)
        ;
      if (k - j > 2) return puts("No"), 0;
      if (k - j > 1) add((((G[i][j]) * 2) ^ (1)), (((G[i][k - 1]) * 2) ^ (0)));
    }
  }
  if (!check(r)) return puts("No"), 0;
  puts("Yes");
  while (l < r) mid = (l + r) >> 1, check(mid) ? (r = mid) : (l = mid + 1);
  assert(check(l));
  for (int i = 1; i <= m; i++)
    if (scc[(((i)*2) ^ (0))] < scc[(((i)*2) ^ (1))]) ans.push_back(i);
  printf("%d %d\n", l, ans.size());
  for (int x : ans) printf("%d ", x);
}
