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 maxn = 5e4 + 2;
int V[maxn], U[maxn], C[maxn], T[maxn], SC[2 * maxn], R;
vector<int> adj[2][2 * maxn], FT;
vector<pair<int, int> > g[maxn];
bitset<2 * maxn> mark;
void dfs(int t, int v) {
  mark[v] = 1;
  for (auto u : adj[t][v]) {
    if (!mark[u]) {
      SC[u] = SC[v];
      dfs(t, u);
    }
  }
  if (!t) FT.push_back(v);
}
inline void SCC(int n) {
  mark = 0;
  FT.clear();
  for (int i = 0; i < 2 * n; i++) {
    if (!mark[i]) dfs(0, i);
  }
  reverse(FT.begin(), FT.end());
  mark = 0;
  R = -1;
  for (auto i : FT) {
    if (!mark[i]) {
      SC[i] = ++R;
      dfs(1, i);
    }
  }
}
inline bool check(int n, int m, int x, bool print = 0) {
  for (int i = 0; i < m; i++) {
    if (T[i] > x) {
      adj[0][2 * i + 1].push_back(2 * i + 0);
      adj[1][2 * i + 0].push_back(2 * i + 1);
    }
  }
  SCC(m);
  bool f = 1;
  vector<int> Q;
  for (int i = 0; i < m; i++) {
    if (SC[2 * i] == SC[2 * i + 1]) {
      f = 0;
      break;
    }
    if (print && SC[2 * i + 1] > SC[2 * i]) Q.push_back(i);
  }
  if (print) {
    cout << "Yes\n";
    cout << x << ' ' << Q.size() << '\n';
    for (auto v : Q) cout << v + 1 << ' ';
    exit(0);
  }
  for (int i = 0; i < m; i++) {
    if (T[i] > x) {
      adj[0][2 * i + 1].pop_back();
      adj[1][2 * i + 0].pop_back();
    }
  }
  return f;
}
inline int bs(int n, int m) {
  int l = -1, r = 1e9 + 1;
  while (r > l + 1) {
    int mid = (l + r) / 2;
    if (check(n, m, mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return r;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> V[i] >> U[i] >> C[i] >> T[i];
    V[i]--;
    U[i]--;
    g[V[i]].push_back(pair<int, int>(C[i], i));
    g[U[i]].push_back(pair<int, int>(C[i], i));
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    int c = 0;
    for (int j = 0; j < (int)g[i].size() - 1; j++) {
      if (g[i][j].first == g[i][j + 1].first) {
        adj[0][2 * g[i][j].second + 0].push_back(2 * g[i][j + 1].second + 1);
        adj[1][2 * g[i][j + 1].second + 1].push_back(2 * g[i][j].second + 0);
        adj[0][2 * g[i][j + 1].second + 0].push_back(2 * g[i][j].second + 1);
        adj[1][2 * g[i][j].second + 1].push_back(2 * g[i][j + 1].second + 0);
        c++;
        if (c > 1) break;
      }
    }
    if (c > 1) {
      cout << "No";
      return 0;
    }
    if (c) {
      for (int j = 0; j < (int)g[i].size() - 1; j++) {
        if ((!j || g[i][j].first != g[i][j - 1].first) &&
            g[i][j].first != g[i][j + 1].first) {
          adj[0][2 * g[i][j].second + 1].push_back(2 * g[i][j].second + 0);
          adj[1][2 * g[i][j].second + 0].push_back(2 * g[i][j].second + 1);
        }
      }
    }
  }
  SCC(m);
  for (int i = 0; i < m; i++) {
    if (SC[2 * i] == SC[2 * i + 1]) {
      cout << "No";
      return 0;
    }
  }
  int x = bs(n, m);
  check(n, m, x, 1);
}
