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;
const int N = 50004;
int n, m, ts, cp, A[N], B[N], Cl[N], Dt[N];
int M[N * 7];
vector<int> U, T, Adj[N], Ad[N * 7], At[N * 7];
vector<pair<int, int> > E;
inline bool CMP(int i, int j) { return (Cl[i] < Cl[j]); }
inline void Add(int v, int u) {
  Ad[v].push_back(u);
  At[u].push_back(v);
}
void DFS(int v) {
  M[v] = 1;
  for (int &u : Ad[v])
    if (!M[u]) DFS(u);
  T.push_back(v);
}
void DFS2(int v) {
  M[v] = cp;
  for (int &u : At[v])
    if (!M[u]) DFS2(u);
}
inline bool Solve(int md) {
  T.clear();
  cp = ts = 0;
  memset(M, 0, sizeof(M));
  for (int i = 0; i < N * 7; i++) {
    Ad[i].clear();
    At[i].clear();
  }
  for (auto X : E) {
    int a = X.first, b = X.second;
    Add(a << 1, b << 1 ^ 1), Add(b << 1, a << 1 ^ 1);
  }
  for (int i = 0; i < m; i++)
    if (Dt[i] > md) Add(i << 1 ^ 1, i << 1);
  ts = m;
  for (int i = 0; i < n; i++)
    if (Adj[i].size()) {
      int p = Adj[i][0];
      for (int j = 1; j < Adj[i].size(); j++) {
        int e = Adj[i][j];
        Add(p << 1 ^ 1, ts << 1 ^ 1);
        Add(ts << 1, p << 1);
        Add(e << 1 ^ 1, ts << 1 ^ 1);
        Add(ts << 1, e << 1);
        Add(p << 1 ^ 1, e << 1);
        Add(e << 1 ^ 1, p << 1);
        p = ts;
        ts++;
      }
    }
  for (int i = 0; i < ts + ts; i++)
    if (!M[i]) DFS(i);
  reverse(T.begin(), T.end());
  memset(M, 0, sizeof(M));
  for (int &v : T)
    if (!M[v]) cp++, DFS2(v);
  for (int i = 0; i < ts; i++)
    if (M[i << 1] == M[i << 1 ^ 1]) return (0);
  return (1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d%d", &A[i], &B[i], &Cl[i], &Dt[i]);
    A[i]--;
    B[i]--;
    U.push_back(Dt[i]);
    Adj[A[i]].push_back(i);
    Adj[B[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    sort(Adj[i].begin(), Adj[i].end(), CMP);
    for (int j = 0; j < Adj[i].size(); j++) {
      int r = j;
      while (r < Adj[i].size() && Cl[Adj[i][j]] == Cl[Adj[i][r]]) r++;
      if (r - j > 2) return !printf("No");
      if (r - j == 2) E.push_back({Adj[i][j], Adj[i][j + 1]}), cnt++;
      j = r - 1;
    }
    if (cnt >= 2) return !printf("No");
  }
  U.push_back(0);
  U.push_back((int)(2e9));
  sort(U.begin(), U.end());
  U.resize(unique(U.begin(), U.end()) - U.begin());
  int l = -1, r = (int)U.size(), md;
  while (r - l > 1) {
    md = (l + r) >> 1;
    if (Solve(U[md]))
      r = md;
    else
      l = md;
  }
  if (r == (int)U.size()) return !printf("No");
  Solve(U[r]);
  printf("Yes\n");
  vector<int> R;
  for (int i = 0; i < m; i++)
    if (M[i << 1] < M[i << 1 ^ 1]) R.push_back(i);
  printf("%d %d\n", U[r], (int)R.size());
  for (int &id : R) printf("%d ", id + 1);
  return (0);
}
