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>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
int n, m;
int from[maxn], to[maxn], cost[maxn], color[maxn];
int fre;
vector<int> g[maxn], e[6 * maxn];
vector<int> ee[6 * maxn];
vector<pair<int, int> > bad;
bool used[6 * maxn];
vector<int> o;
int comp[6 * maxn];
vector<int> ans;
bool cmp(int i, int j) { return color[i] < color[j]; }
void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < (int)(e[v]).size(); i++) {
    int to = e[v][i];
    if (used[to]) continue;
    dfs(to);
  }
  o.push_back(v);
}
void go(int v, int cc) {
  comp[v] = cc;
  for (int i = 0; i < (int)(ee[v]).size(); i++) {
    int to = ee[v][i];
    if (comp[to]) continue;
    go(to, cc);
  }
}
bool check(int value) {
  for (int i = 0; i < 8 * m; i++) {
    e[i].clear();
    ee[i].clear();
  }
  for (int i = 0; i < (int)(bad).size(); i++) {
    int u = bad[i].first;
    int v = bad[i].second;
    e[2 * u].push_back(2 * v + 1);
    e[2 * v].push_back(2 * u + 1);
  }
  for (int i = 0; i < m; i++)
    if (cost[i] > value) {
      e[2 * i + 1].push_back(2 * i);
    }
  fre = m;
  for (int i = 0; i < n; i++)
    if (!g[i].empty()) {
      int prev = -1;
      for (int j = 0; j < (int)(g[i]).size(); j++) {
        int cur = g[i][j];
        e[2 * fre].push_back(2 * cur);
        e[2 * cur + 1].push_back(2 * fre + 1);
        if (prev != -1) {
          e[2 * (fre - 1) + 1].push_back(2 * fre + 1);
          e[2 * cur + 1].push_back(2 * (fre - 1));
          e[2 * fre].push_back(2 * (fre - 1));
        }
        prev = cur;
        fre++;
      }
    }
  memset(used, false, sizeof(used));
  o.clear();
  for (int i = 0; i < 2 * fre; i++)
    if (!used[i]) {
      dfs(i);
    }
  reverse((o).begin(), (o).end());
  for (int i = 0; i < 2 * fre; i++) {
    for (int j = 0; j < (int)(e[i]).size(); j++) {
      int to = e[i][j];
      ee[to].push_back(i);
    }
  }
  memset(comp, 0, sizeof(comp));
  int cc = 1;
  for (int i = 0; i < 2 * fre; i++) {
    int cur = o[i];
    if (comp[cur]) continue;
    go(cur, cc++);
  }
  ans.clear();
  for (int i = 0; i < fre; i++) {
    if (comp[2 * i] == comp[2 * i + 1]) {
      return false;
    }
    if (comp[2 * i] < comp[2 * i + 1] && i < m) {
      ans.push_back(i);
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  vector<int> wei;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d%d", &from[i], &to[i], &color[i], &cost[i]);
    --from[i];
    --to[i];
    g[from[i]].push_back(i);
    g[to[i]].push_back(i);
    wei.push_back(cost[i]);
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end(), cmp);
    int two = 0;
    for (int j = 0; j < (int)(g[i]).size();) {
      int k = j;
      while (k < (int)(g[i]).size() && color[g[i][j]] == color[g[i][k]]) k++;
      if (k - j > 2) {
        cout << "No" << endl;
        return 0;
      }
      if (k - j == 2) {
        bad.push_back(make_pair(g[i][j], g[i][j + 1]));
        two++;
        if (two > 1) {
          cout << "No" << endl;
          return 0;
        }
      }
      j = k;
    }
  }
  wei.push_back(0);
  sort((wei).begin(), (wei).end());
  wei.erase(unique((wei).begin(), (wei).end()), wei.end());
  int l = -1;
  int r = (int)(wei).size();
  while (l < r - 1) {
    int mid = (l + r) >> 1;
    if (check(wei[mid])) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (r == (int)(wei).size()) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << wei[r] << " " << (int)(ans).size() << endl;
  for (int i = 0; i < (int)(ans).size(); i++) {
    printf("%d ", ans[i] + 1);
  }
  return 0;
}
