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 = (5 * 10000 + 5) * 6;
int n, m, from[N], to[N], t[N], c[N], f[N], s[N], cnt_comp, comp[N];
bool vis[N];
vector<int> adj[N], in[N], out[N], L;
void add_edge(int v, int u) { out[v].push_back(u), in[u].push_back(v); }
void add_clause(int v, int u, int x, int y) {
  add_edge(v << 1 | !x, u << 1 | y);
  add_edge(u << 1 | !y, v << 1 | x);
}
void dfs(int v) {
  vis[v] = true;
  for (auto v : out[v])
    if (!vis[v]) dfs(v);
  L.push_back(v);
}
void dfs_c(int v) {
  comp[v] = cnt_comp;
  for (auto u : in[v])
    if (!comp[u]) dfs_c(u);
}
bool check(int x) {
  for (int i = 0; i < N; i++)
    in[i].clear(), out[i].clear(), comp[i] = 0, vis[i] = false;
  L.clear();
  cnt_comp = 0;
  for (int v = 0; v < n; v++)
    if (f[v] != -1) add_clause(f[v], s[v], 0, 0);
  int s = m;
  for (int v = 0; v < n; v++) {
    int d = (int)(adj[v].size());
    for (int i = s; i + 1 < s + d; i++) {
      add_clause(i, i + 1, 1, 0);
      add_clause(adj[v][i - s], i + 1, 1, 0);
    }
    for (int i = s; i < s + d; i++) add_clause(i, adj[v][i - s], 1, 1);
    s += d;
  }
  for (int v = 0; v < n; v++)
    for (auto i : adj[v])
      if (t[i] > x) add_edge(i << 1, i << 1 | 1);
  for (int i = 0; i < N; i++)
    if (!vis[i]) dfs(i);
  reverse(L.begin(), L.end());
  for (auto v : L)
    if (!comp[v]) {
      cnt_comp++;
      dfs_c(v);
    }
  for (int i = 0; (i << 1 | 1) < N; i++)
    if (comp[i << 1] == comp[i << 1 | 1]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i] >> c[i] >> t[i];
    adj[--from[i]].push_back(i);
    adj[--to[i]].push_back(i);
  }
  for (int v = 0; v < n; v++) {
    int col = -1;
    unordered_map<int, int> cnt;
    f[v] = s[v] = -1;
    for (auto i : adj[v]) {
      cnt[c[i]]++;
      if (cnt[c[i]] == 2) {
        if (col != -1) return cout << "No\n", 0;
        col = c[i];
      }
      if (cnt[c[i]] > 2) return cout << "No\n", 0;
    }
    for (auto i : adj[v]) {
      if (c[i] == col) {
        if (f[v] != -1)
          s[v] = i;
        else
          f[v] = i;
      }
    }
  }
  int l = -1, r = 1e9 + 10;
  while (l + 1 < r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (r > 1e9) return cout << "No\n", 0;
  check(r);
  cout << "Yes\n";
  cout << r << ' ';
  vector<int> o;
  for (int i = 0; i < m; i++)
    if (comp[i << 1] > comp[i << 1 | 1]) o.push_back(i);
  cout << (int)(o.size()) << '\n';
  for (auto i : o) cout << i + 1 << ' ';
  cout << '\n';
  return 0;
}
