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 maxin = 5e4 + 10, maxn = 3e5 + 10, inf = 1e9 + 1;
int n, m, l, pos, col[maxn], sts[maxn], answer, ans[maxin], ntscc[maxn],
    comp[maxin], num;
vector<int> vec[maxin], adj[maxn], adj2[maxn], co[maxn], scc;
bitset<maxn> mark, mark2, bad;
pair<pair<int, int>, int> e[maxin];
bool flag;
bool cmp(const int &i, const int &j) { return col[i] < col[j]; }
int nt(int v) { return v < l ? v + l : v - l; }
void cnd(int v, int u) {
  adj[nt(v)].push_back(u);
  adj[nt(u)].push_back(v);
  adj2[u].push_back(nt(v));
  adj2[v].push_back(nt(u));
  return;
}
void dfs(int v) {
  mark[v] = true;
  for (auto u : adj[v])
    if (!mark[u]) dfs(u);
  scc.push_back(v);
  return;
}
void dfs2(int v, int color) {
  co[color].push_back(v);
  mark[v] = true;
  col[v] = color;
  for (auto u : adj2[v])
    if (!mark[u]) dfs2(u, color);
  return;
}
void dfs3(int v) {
  if (mark2[nt(v)]) bad[col[nt(v)]] = true;
  for (auto u : co[col[v]]) mark2[u] = true, mark[u] = true;
  for (auto u : co[col[v]])
    for (auto u2 : adj[u])
      if (!mark[u2]) dfs3(u2);
  for (auto u : co[col[v]]) mark2[u] = false;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  l = 3 * m;
  for (int i = 0, v, u, c, t; i < m; ++i) {
    cin >> v >> u >> c >> t;
    vec[--v].push_back(i);
    vec[--u].push_back(i);
    e[i] = {{c, t}, v + u};
    comp[num++] = c;
  }
  sort(comp, comp + num);
  num = unique(comp, comp + num) - comp;
  for (int i = 0; i < m; ++i)
    e[i].first.first = lower_bound(comp, comp + num, e[i].first.first) - comp;
  pos = m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0, se = vec[i].size(); j < se; ++j, ++pos) {
      cnd(nt(vec[i][j]), pos);
      if (j) cnd(nt(pos - 1), pos), cnd(nt(pos - 1), nt(vec[i][j]));
    }
    int cnt = 0, c = 0;
    for (auto j : vec[i])
      if (!mark[e[j].first.first]) {
        mark[e[j].first.first] = true;
        ++cnt;
      } else
        c = e[j].first.first;
    if (int(vec[i].size()) - cnt >= 2) return cout << "No\n", 0;
    for (auto j : vec[i]) mark[e[j].first.first] = false;
    if (int(vec[i].size()) == cnt) continue;
    int v = -1, u = -1;
    for (auto j : vec[i])
      if (e[j].first.first == c) {
        if (~v)
          u = j;
        else
          v = j;
      }
    cnd(v, u);
  }
  for (int i = 0; i < (l << 1); ++i)
    if (!mark[i]) dfs(i);
  reverse(scc.begin(), scc.end());
  mark.reset();
  int color = 0;
  for (auto i : scc)
    if (!mark[i]) dfs2(i, color++);
  for (int i = 0; i < l; ++i)
    if (col[i] == col[i + l]) return cout << "No\n", 0;
  cout << "Yes\n";
  mark.reset();
  for (int i = 0; i < (l << 1); ++i) sort(adj[i].begin(), adj[i].end(), cmp);
  for (auto i : scc)
    if (!mark[i]) dfs3(i);
  for (int i = 0; i < (l << 1); ++i) ntscc[col[i]] = col[nt(i)];
  int begin = -1, end = 1e9, mid;
  while (end - begin > 1) {
    flag = true;
    mid = (begin + end) >> 1;
    memset(sts, -1, sizeof(sts));
    for (int i = 0; i < m; ++i)
      if (e[i].first.second > mid) {
        if (bad[col[i + l]] || sts[col[i]] == 1 || !sts[col[i + l]])
          flag = false;
        sts[col[i + l]] = 1, sts[col[i]] = 0;
      }
    if (!flag)
      begin = mid;
    else {
      end = mid, answer = 0;
      for (int i = color - 1; ~i; --i)
        if (sts[i] == -1) sts[i] = 1, sts[ntscc[i]] = 0;
      for (int i = 0; i < m; ++i)
        if (sts[col[i]]) ans[answer++] = i + 1;
    }
  }
  cout << end << ' ' << answer << '\n';
  for (int i = 0; i < answer; ++i) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}
