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 = 5e4 + 7;
const int S = 3e5 + 7;
int n, m;
vector<int> G[N];
int v[N];
int u[N];
int c[N];
int t[N];
vector<int> val;
struct sat2 {
  vector<int> imp[S];
  bitset<S> vis;
  bitset<S> res;
  vector<int> post;
  int last[N];
  int ile[N];
  void dfs_rev(int v) {
    vis[v] = 1;
    for (auto it : imp[v ^ 1]) {
      if (!vis[it ^ 1]) dfs_rev(it ^ 1);
    }
    post.push_back(v);
  }
  void dfs_mark(int v) {
    vis[v] = 1;
    res[v] = !vis[v ^ 1];
    for (auto it : imp[v]) {
      if (!vis[it]) dfs_mark(it);
    }
  }
  void add(int a, int b) {
    imp[a ^ 1].push_back(b);
    imp[b ^ 1].push_back(a);
  }
  bool solve(int k) {
    for (int i = 1; i <= m; ++i) {
      if (t[i] > k) add(2 * i ^ 1, 2 * i ^ 1);
    }
    int curr = m;
    for (int v = 1; v <= n; ++v) {
      for (auto it : G[v]) last[c[it]] = ile[c[it]] = 0;
      for (auto it : G[v]) {
        ++ile[c[it]];
        if (ile[c[it]] == 3) return 0;
      }
      for (auto it : G[v]) {
        if (last[c[it]]) add(2 * it, 2 * last[c[it]]);
        last[c[it]] = it;
      }
      for (int i = 0; i < G[v].size(); ++i) {
        int it = G[v][i];
        ++curr;
        if (i > 0) {
          add(2 * (curr - 1) ^ 1, 2 * it ^ 1);
          add(2 * (curr - 1) ^ 1, 2 * curr);
        }
        add(2 * it ^ 1, 2 * curr);
      }
    }
    for (int v = 2; v <= 2 * curr + 1; ++v) {
      if (!vis[v]) dfs_rev(v);
    }
    reverse((post).begin(), (post).end());
    vis.reset();
    for (auto v : post) {
      if (!vis[v]) dfs_mark(v);
    }
    for (int v = 2; v <= 2 * curr + 1; ++v) {
      for (auto it : imp[v]) {
        if (res[v] && !res[it]) return 0;
      }
    }
    return 1;
  }
  void print() {
    int ile = 0;
    for (int i = 1; i <= m; ++i) {
      if (res[2 * i]) ++ile;
    }
    cout << ile << '\n';
    for (int i = 1; i <= m; ++i) {
      if (res[2 * i]) cout << i << " ";
    }
  }
  sat2() {}
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> v[i] >> u[i] >> c[i] >> t[i];
    G[v[i]].push_back(i);
    G[u[i]].push_back(i);
    val.push_back(c[i]);
  }
  sort((val).begin(), (val).end());
  val.erase(unique((val).begin(), (val).end()), val.end());
  for (int i = 1; i <= m; ++i) {
    c[i] = lower_bound((val).begin(), (val).end(), c[i]) - val.begin() + 1;
  }
  int l = 0, r = 1e9;
  while (l < r) {
    int m = (l + r) / 2;
    if (m == r) --m;
    sat2 sat;
    if (sat.solve(m))
      r = m;
    else
      l = m + 1;
  }
  sat2 sat;
  if (sat.solve(l)) {
    cout << "Yes" << '\n' << l << " ";
    sat.print();
  } else
    cout << "No";
}
