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 = 1e5 + 20;
vector<int> adj[maxn], out[maxn], in[maxn], topol;
int tah, c[maxn], t[maxn], color[maxn], n, m, now, from[maxn], to[maxn],
    checked[maxn];
bool visited[maxn], sat[maxn];
bool cmp(int a, int b) { return c[a] < c[b]; }
void add(int a, int b) {
  out[a].push_back(b);
  in[b].push_back(a);
}
void dfs(int v) {
  if (visited[v]) return;
  visited[v] = 1;
  for (auto u : out[v])
    if (!visited[u]) dfs(u);
  for (auto x : {from[v / 2], to[v / 2]})
    if (v % 2 == 0 && checked[x] < 2) {
      checked[x]++;
      for (auto e : adj[x])
        if (e != v / 2) dfs(e * 2 + 1);
    }
  topol.push_back(v);
}
void sfd(int v) {
  if (color[v]) return;
  color[v] = now;
  for (auto u : in[v])
    if (!color[u]) sfd(u);
  for (auto x : {from[v / 2], to[v / 2]})
    if (v % 2 == 1 && checked[x] < 8) {
      checked[x]++;
      for (auto e : adj[x])
        if (e != v / 2) sfd(e * 2);
    }
}
bool check(long long x) {
  for (int i = 0; i < 2 * m; i++) out[i].clear(), in[i].clear();
  tah = 2 * m;
  memset(checked, 0, sizeof checked);
  for (int i = 1; i <= n; i++) {
    if (adj[i].empty()) continue;
    for (int j = 0; j < (int)adj[i].size(); j++) {
      int k = j;
      while (j + 1 < (int)adj[i].size() && c[adj[i][j]] == c[adj[i][j + 1]])
        j++;
      if (j - k + 1 < 2) continue;
      int a = adj[i][k], b = adj[i][k + 1];
      add(2 * a + 1, 2 * b);
      add(2 * b + 1, 2 * a);
    }
    for (auto e : adj[i])
      if (t[e] > x) add(2 * e, 2 * e + 1);
  }
  memset(visited, 0, sizeof visited);
  memset(color, 0, sizeof color);
  now = 0;
  for (int i = 0; i < tah; i++)
    if (!visited[i]) dfs(i);
  reverse(topol.begin(), topol.end());
  for (auto v : topol)
    if (!color[v]) {
      now++;
      sfd(v);
    }
  for (int i = 0; i < m; i++) {
    if (color[2 * i] == color[2 * i + 1]) return 0;
    sat[i] = (color[2 * i] > color[2 * i + 1]);
  }
  return 1;
}
int main() {
  cin >> n >> m;
  tah = 2 * m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b >> c[i] >> t[i];
    adj[a].push_back(i);
    adj[b].push_back(i);
    from[i] = a, to[i] = b;
  }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end(), cmp);
    for (int j = 0; j < (int)adj[i].size(); j++) {
      int k = j;
      while (j + 1 < (int)adj[i].size() && c[adj[i][j]] == c[adj[i][j + 1]])
        j++;
      if (j - k + 1 > 2) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  long long l = -1, r = 1e10;
  if (!check(r)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  while (r - l > 1) {
    long long m = (r + l) / 2;
    if (check(m))
      r = m;
    else
      l = m;
  }
  check(r);
  vector<int> ans;
  for (int i = 0; i < m; i++)
    if (sat[i]) ans.push_back(i);
  cout << r << " " << ans.size() << endl;
  for (auto e : ans) cout << e + 1 << " ";
}
