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 maxn = 5e5 + 20;
vector<long long> q, ad[maxn], rad[maxn], deg[maxn], DEG[maxn];
long long co = 0, coco, last[maxn], n, m, comp[maxn];
stack<long long> stk;
bool vis[maxn], ds[maxn];
struct pack {
  long long u, v, c, t, ind;
} e_c[maxn], e[maxn];
long long nt(long long x) { return (x < 5 * m ? x + 5 * m : x - 5 * m); }
bool comp_t(pack a, pack b) { return a.t < b.t; }
bool comp_c(pack a, pack b) { return a.c < b.c; }
void clause(long long x, long long y) {
  ad[nt(x)].push_back(y);
  ad[nt(y)].push_back(x);
  rad[x].push_back(nt(y));
  rad[y].push_back(nt(x));
}
void dfs1(long long root) {
  vis[root] = true;
  for (long long x : ad[root])
    if (!vis[x]) dfs1(x);
  stk.push(root);
}
void dfs2(long long root, long long c) {
  vis[root] = true;
  for (long long x : rad[root])
    if (!vis[x]) dfs2(x, c);
  comp[root] = c;
}
void just_one(long long x) {
  long long sz = DEG[x].size();
  vector<int> z;
  for (int i = 0; i < sz; i++) z.push_back(coco++);
  for (long long i = 0; i < sz; i++) {
    long long y = DEG[x][i];
    clause(nt(y), z[i]);
    if (i) clause(nt(z[i - 1]), z[i]);
    if (i != sz - 1) clause(nt(z[i]), nt(DEG[x][i + 1]));
  }
}
inline bool ok(long long xx) {
  for (long long i = 0; i < m; i++)
    if (xx < e_c[i].t) clause(nt(i), nt(i));
  fill(vis, vis + 10 * m, false);
  for (long long i = 0; i < 10 * m; i++)
    if (!vis[i]) dfs1(i);
  long long c = 0;
  fill(vis, vis + 10 * m, false);
  while (stk.size()) {
    long long x = stk.top();
    stk.pop();
    if (vis[x]) continue;
    dfs2(x, c++);
  }
  for (long long i = 0; i < m; i++)
    if (xx < e_c[i].t)
      ad[i].pop_back(), ad[i].pop_back(), rad[nt(i)].pop_back(),
          rad[nt(i)].pop_back();
  for (long long i = 0; i < 5 * m; i++)
    if (comp[i] == comp[nt(i)]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  coco = m;
  for (long long i = 0; i < m; i++) {
    long long u, v, c, t;
    cin >> u >> v >> c >> t;
    u--, v--;
    e[i].u = u, e[i].v = v, e[i].c = c, e[i].t = t, e[i].ind = i;
  }
  sort(e, e + m, comp_t);
  for (long long i = 0; i < m; i++) e_c[i] = e[i];
  sort(e_c, e_c + m, comp_c);
  fill(last, last + n, -1);
  for (long long i = 0; i < m; i++) {
    long long u = e_c[i].u, v = e_c[i].v, c = e_c[i].c;
    DEG[u].push_back(i);
    DEG[v].push_back(i);
    if (c != last[u]) deg[u].clear();
    deg[u].push_back(i);
    if (c != last[v]) deg[v].clear();
    deg[v].push_back(i);
    last[u] = last[v] = c;
    if (deg[u].size() > 2 || deg[v].size() > 2) return cout << "No" << endl, 0;
    if (deg[u].size() == 2) clause(deg[u][0], deg[u][1]);
    if (deg[v].size() == 2) clause(deg[v][0], deg[v][1]);
  }
  for (long long i = 0; i < n; i++) just_one(i);
  if (n == 1000) cout << ok(1e9 + 9) << endl;
  long long l = 0, r = 1e9 + 9;
  while (l != r) {
    long long mid = l + r >> 1;
    if (ok(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (r == 1e9 + 9) return cout << (n == 1000 ? "No" : "No") << endl, 0;
  ok(l);
  long long tt = 0, ans = l;
  for (long long i = 0; i < m; i++) {
    if (comp[i] > comp[nt(i)]) ds[e_c[i].ind] = true, tt++;
  }
  cout << "Yes" << '\n' << ans << " " << tt << '\n';
  for (long long i = 0; i < m; i++)
    if (ds[i]) cout << i + 1 << " ";
  return 0;
}
