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 long long N = 1e6 + 10, NM = 1 << 16, MOD = 1e9 + 7, INF = 1e9 + 10,
                SQ = 640, LOG = 25;
long long n, m, x1, x2, z, x, y, y2, maxi, c[N], t[N], color[N], mini, ptr, k,
    q, pos, posi, l, r;
pair<long long, long long> pr[N];
vector<long long> v[N], in[N], out[N], ans, topo;
bool mark[N];
map<int, int> dp, cnt;
void bzn(long long x, long long y) {
  out[x ^ 1].push_back(y);
  in[y].push_back(x ^ 1);
  out[y ^ 1].push_back(x);
  in[x].push_back(y ^ 1);
}
void dfs(long long x) {
  if (mark[x]) return;
  mark[x] = 1;
  for (int i = 0; i < out[x].size(); i++) {
    dfs(out[x][i]);
  }
  topo.push_back(x);
}
void backdfs(long long x, long long y) {
  if (mark[x]) return;
  mark[x] = 1;
  color[x] = y;
  for (int i = 0; i < in[x].size(); i++) {
    backdfs(in[x][i], y);
  }
}
bool check(long long lim) {
  for (int i = 0; i < N; i++) {
    in[i].clear();
    out[i].clear();
  }
  pos = m - 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      x = v[i][j];
      cnt[c[x]]++;
      if (cnt[c[x]] > 2) {
        cout << "No";
        exit(0);
      }
      if (dp[c[x]] >= 0) {
        bzn(2 * dp[c[x]], 2 * x);
      } else {
        dp[c[x]] = x;
      }
    }
    for (int j = 0; j < v[i].size(); j++) {
      x = v[i][j];
      cnt[c[x]] = 0;
      dp[c[x]] = -1;
      pos++;
      bzn(2 * x + 1, 2 * pos);
      if (j < v[i].size() - 1) bzn(2 * pos + 1, 2 * v[i][j + 1] + 1);
      if (j) bzn(2 * pos - 1, 2 * pos);
    }
  }
  for (int i = 0; i < m; i++) {
    if (t[i] > lim) {
      out[2 * i].push_back(2 * i + 1);
      in[2 * i + 1].push_back(2 * i);
    }
  }
  topo.clear();
  ans.clear();
  memset(mark, 0, sizeof(mark));
  for (int i = 0; i <= 2 * pos + 1; i++) {
    if (!mark[i]) dfs(i);
  }
  long long cc = 1;
  memset(mark, 0, sizeof(mark));
  memset(color, 0, sizeof(color));
  for (int i = topo.size() - 1; i >= 0; i--) {
    if (!mark[topo[i]]) backdfs(topo[i], cc++);
  }
  for (int i = 0; i <= pos; i++) {
    if (color[2 * i] == color[2 * i + 1]) {
      return 0;
    }
    if (i < m && color[2 * i] > color[2 * i + 1]) {
      ans.push_back(i);
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> pr[i].first >> pr[i].second >> c[i] >> t[i];
    v[pr[i].first].push_back(i);
    v[pr[i].second].push_back(i);
    dp[c[i]] = -1;
  }
  long long be = -1, en = 1e10, mid;
  while (en - be > 1) {
    mid = en + be >> 1;
    if (check(mid)) {
      en = mid;
    } else {
      be = mid;
    }
  }
  if (en == 1e10) {
    cout << "No";
    return 0;
  }
  cout << "Yes" << endl;
  check(en);
  cout << en << ' ' << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << " ";
  }
}
