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>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const long long maxn = 5e4 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 400;
const long long nott = (1 << 19);
vector<long long> out[2 * nott];
vector<long long> in[2 * nott];
bool chosss[2 * nott];
vector<long long> topol;
bitset<2 * nott> vis;
long long moa[2 * nott];
void sfd(long long a, long long b) {
  moa[a] = b;
  vis[a] = 1;
  for (auto v : in[a]) {
    if (!vis[v]) {
      sfd(v, b);
    }
  }
}
void dfs(long long a) {
  vis[a] = 1;
  for (auto v : out[a]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
  topol.push_back(a);
}
bool is_ok(long long n) {
  topol.clear();
  vis = 0;
  topol.reserve(2 * n);
  for (long long i = 0; i < n; i++) {
    chosss[i] = 0;
    chosss[i ^ nott] = 0;
  }
  for (long long i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
    if (!vis[i ^ nott]) {
      dfs(i ^ nott);
    }
  }
  vis = 0;
  reverse(topol.begin(), topol.end());
  long long cnt = 0;
  for (auto v : topol) {
    if (!vis[v]) {
      sfd(v, cnt);
      cnt++;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (moa[i] == moa[i ^ nott]) {
      if (n == 2344 * 3) {
        cout << i << ":" << moa[i] << ' ' << (i ^ nott) << endl;
      }
      return 0;
    }
    if (moa[i] > moa[i ^ nott]) {
      chosss[i] = 1;
    }
  }
  return 1;
}
bool chose[maxn];
vector<pair<long long, long long> > yal;
void add_yal(long long a, long long b) {
  out[a].push_back(b);
  in[b].push_back(a);
  yal.push_back(make_pair(a, b));
}
void pop_yal() {
  out[yal.back().first].pop_back();
  in[yal.back().second].pop_back();
  yal.pop_back();
}
void add_shart(long long a, long long b) {
  add_yal(a ^ nott, b);
  add_yal(b ^ nott, a);
}
void pop_shart() {
  pop_yal();
  pop_yal();
}
vector<long long> ger[maxn];
long long s[maxn];
long long t[maxn];
long long w[maxn];
long long c[maxn];
bool check(long long W, long long n, long long m) {
  long long cnt = 0;
  for (long long i = 0; i < m; i++) {
    if (w[i] > W) {
      cnt++;
      if (n == 9483) {
        cout << "WTF?!\n";
      }
      add_shart((i * 3) ^ nott, (i * 3) ^ nott);
    }
  }
  bool ans = is_ok(m * 3);
  for (long long i = 0; i < m; i++) {
    chose[i] = chosss[i * 3];
  }
  while (cnt--) {
    pop_shart();
  }
  return ans;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> comp;
  comp.push_back(0);
  for (long long i = 0; i < m; i++) {
    cin >> s[i] >> t[i] >> c[i] >> w[i];
    ger[s[i]].push_back(i);
    ger[t[i]].push_back(i);
    comp.push_back(w[i]);
  }
  {
    sort(comp.begin(), comp.end());
    auto it = unique(comp.begin(), comp.end());
    comp.resize(it - comp.begin());
  }
  for (long long i = 1; i <= n; i++) {
    long long last = -1;
    for (auto v : ger[i]) {
      long long u = 3 * v;
      add_shart(u ^ nott, u + 1);
      if (last != -1) {
        add_shart((last + 1) ^ nott, u + 1);
        add_shart((last + 1) ^ nott, u ^ nott);
      }
      last = u;
    }
  }
  for (long long i = 1; i <= n; i++) {
    map<long long, vector<long long> > ml;
    for (auto v : ger[i]) {
      ml[c[v]].push_back(v);
    }
    for (auto& VEC : ml) {
      long long last = -1;
      for (auto v : VEC.second) {
        long long u = 3 * v;
        add_shart(u, (u + 2) ^ nott);
        if (last != -1) {
          add_shart((last + 2), (u + 2) ^ nott);
          add_shart((last + 2), u);
        }
        last = u;
      }
    }
  }
  if (!check(comp.back(), n, m)) {
    cout << "No";
    return 0;
  }
  long long b = -1;
  long long e = comp.size() - 1;
  cout << "Yes\n";
  while (e - b > 1) {
    long long mid = (e + b) / 2;
    if (check(comp[mid], n, m)) {
      e = mid;
    } else {
      b = mid;
    }
  }
  check(comp[e], n, m);
  vector<long long> ans;
  for (long long i = 0; i < m; i++) {
    if (chose[i]) {
      ans.push_back(i + 1);
    }
  }
  cout << comp[e] << ' ' << ans.size() << endl;
  for (auto v : ans) {
    cout << v << ' ';
  }
}
